From 2d8de559b956ea21a3402e780d0f561693a31380 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 30 Aug 2026 15:20:23 +0200 Subject: [PATCH] Split the Huawei LTE user flow init from its data (#180800) --- .../components/huawei_lte/test_config_flow.py | 63 ++++++++++++++++--- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/tests/components/huawei_lte/test_config_flow.py b/tests/components/huawei_lte/test_config_flow.py index 73dfa0945de7..27975cf5e26b 100644 --- a/tests/components/huawei_lte/test_config_flow.py +++ b/tests/components/huawei_lte/test_config_flow.py @@ -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()