Clean up Fritz options flow (#109111)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
a8915b85a4
commit
f7909ee34a
2 changed files with 27 additions and 28 deletions
|
@ -9,11 +9,13 @@ from fritzconnection.core.exceptions import (
|
|||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.device_tracker import (
|
||||
CONF_CONSIDER_HOME,
|
||||
DEFAULT_CONSIDER_HOME,
|
||||
)
|
||||
from homeassistant.components.fritz.const import (
|
||||
CONF_OLD_DISCOVERY,
|
||||
DOMAIN,
|
||||
ERROR_AUTH_INVALID,
|
||||
ERROR_CANNOT_CONNECT,
|
||||
|
@ -453,28 +455,24 @@ async def test_ssdp_exception(hass: HomeAssistant, mock_get_source_ip) -> None:
|
|||
assert result["step_id"] == "confirm"
|
||||
|
||||
|
||||
async def test_options_flow(
|
||||
hass: HomeAssistant, fc_class_mock, mock_get_source_ip
|
||||
) -> None:
|
||||
async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
"""Test options flow."""
|
||||
|
||||
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_DATA)
|
||||
mock_config.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.fritz.config_flow.FritzConnection",
|
||||
side_effect=fc_class_mock,
|
||||
), patch("homeassistant.components.fritz.common.FritzBoxTools"):
|
||||
result = await hass.config_entries.options.async_init(mock_config.entry_id)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
result = await hass.config_entries.options.async_init(mock_config.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_CONSIDER_HOME: 37,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(mock_config.entry_id)
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_CONSIDER_HOME: 37,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert mock_config.options[CONF_CONSIDER_HOME] == 37
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_OLD_DISCOVERY: False,
|
||||
CONF_CONSIDER_HOME: 37,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue