Use new fixtures in devolo Home Control tests (#45669)

This commit is contained in:
Guido Schmitz 2021-01-29 03:14:39 +01:00 committed by GitHub
parent eb370e9494
commit 8b3156ea82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
"""Test the devolo_home_control config flow."""
from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant.components.devolo_home_control.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
@ -24,9 +26,6 @@ async def test_form(hass):
"homeassistant.components.devolo_home_control.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
return_value=True,
), patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
return_value="123456",
):
@ -48,6 +47,7 @@ async def test_form(hass):
assert len(mock_setup_entry.mock_calls) == 1
@pytest.mark.credentials_invalid
async def test_form_invalid_credentials(hass):
"""Test if we get the error message on invalid credentials."""
await setup.async_setup_component(hass, "persistent_notification", {})
@ -57,10 +57,6 @@ async def test_form_invalid_credentials(hass):
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
return_value=False,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"username": "test-username", "password": "test-password"},
@ -74,9 +70,6 @@ async def test_form_already_configured(hass):
with patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
return_value="123456",
), patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
return_value=True,
):
MockConfigEntry(domain=DOMAIN, unique_id="123456", data={}).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
@ -103,9 +96,6 @@ async def test_form_advanced_options(hass):
"homeassistant.components.devolo_home_control.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
return_value=True,
), patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
return_value="123456",
):