mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use new fixtures in devolo Home Control tests (#45669)
This commit is contained in:
parent
eb370e9494
commit
8b3156ea82
@ -1,6 +1,8 @@
|
|||||||
"""Test the devolo_home_control config flow."""
|
"""Test the devolo_home_control config flow."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, data_entry_flow, setup
|
||||||
from homeassistant.components.devolo_home_control.const import DOMAIN
|
from homeassistant.components.devolo_home_control.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
@ -24,9 +26,6 @@ async def test_form(hass):
|
|||||||
"homeassistant.components.devolo_home_control.async_setup_entry",
|
"homeassistant.components.devolo_home_control.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry, patch(
|
) 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",
|
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
|
||||||
return_value="123456",
|
return_value="123456",
|
||||||
):
|
):
|
||||||
@ -48,6 +47,7 @@ async def test_form(hass):
|
|||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.credentials_invalid
|
||||||
async def test_form_invalid_credentials(hass):
|
async def test_form_invalid_credentials(hass):
|
||||||
"""Test if we get the error message on invalid credentials."""
|
"""Test if we get the error message on invalid credentials."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
@ -57,16 +57,12 @@ async def test_form_invalid_credentials(hass):
|
|||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with patch(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
|
result["flow_id"],
|
||||||
return_value=False,
|
{"username": "test-username", "password": "test-password"},
|
||||||
):
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
|
||||||
result["flow_id"],
|
|
||||||
{"username": "test-username", "password": "test-password"},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_form_already_configured(hass):
|
async def test_form_already_configured(hass):
|
||||||
@ -74,9 +70,6 @@ async def test_form_already_configured(hass):
|
|||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
|
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
|
||||||
return_value="123456",
|
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)
|
MockConfigEntry(domain=DOMAIN, unique_id="123456", data={}).add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
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",
|
"homeassistant.components.devolo_home_control.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry, patch(
|
) 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",
|
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.uuid",
|
||||||
return_value="123456",
|
return_value="123456",
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user