Split the Huawei LTE user flow init from its data (#180800)

This commit is contained in:
Franck Nijhof
2026-08-30 15:20:23 +02:00
committed by GitHub
parent e3ac126b04
commit 2d8de559b9
@@ -63,7 +63,14 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=config_entries.ConfigFlowContext(source=config_entries.SOURCE_USER),
data=None,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=None,
)
assert result["type"] is FlowResultType.FORM
@@ -80,12 +87,23 @@ async def test_urlize_plain_host(
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=config_entries.ConfigFlowContext(source=config_entries.SOURCE_USER),
data=user_input,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert user_input[CONF_URL] == f"http://{host}/"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=user_input,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# The form comes back offering the URL the plain host was turned into
schema = result["data_schema"].schema
url_key = next(key for key in schema if key == CONF_URL)
assert url_key.default() == f"http://{host}/"
async def test_already_configured(
@@ -113,7 +131,14 @@ async def test_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=config_entries.ConfigFlowContext(source=config_entries.SOURCE_USER),
data=FIXTURE_USER_INPUT,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=FIXTURE_USER_INPUT,
)
assert result["type"] is FlowResultType.ABORT
@@ -142,9 +167,15 @@ async def test_connection_errors(
"""Test we show user form on various errors."""
requests_mock.request(ANY, ANY, exc=exception)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=FIXTURE_USER_INPUT | data_patch,
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=FIXTURE_USER_INPUT | data_patch,
)
assert result["type"] is FlowResultType.FORM
@@ -256,7 +287,14 @@ async def test_login_error(
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=config_entries.ConfigFlowContext(source=config_entries.SOURCE_USER),
data={**FIXTURE_USER_INPUT, **fixture_override},
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={**FIXTURE_USER_INPUT, **fixture_override},
)
assert result["type"] is FlowResultType.FORM
@@ -286,7 +324,14 @@ async def test_success(hass: HomeAssistant, login_requests_mock, scheme: str) ->
result = await hass.config_entries.flow.async_init(
DOMAIN,
context=config_entries.ConfigFlowContext(source=config_entries.SOURCE_USER),
data=user_input,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=user_input,
)
await hass.async_block_till_done()