From 24a7f372141b1dec7781ff8a13992217859cc89a Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 30 Aug 2026 15:26:37 +0200 Subject: [PATCH] Split the Atag user flow init from its data (#180762) --- tests/components/atag/test_config_flow.py | 56 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/tests/components/atag/test_config_flow.py b/tests/components/atag/test_config_flow.py index 59dd7fe8b485..b7d074ac5918 100644 --- a/tests/components/atag/test_config_flow.py +++ b/tests/components/atag/test_config_flow.py @@ -36,7 +36,15 @@ async def test_adding_second_device( await init_integration(hass, aioclient_mock, unique_id=UID) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT + 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=USER_INPUT, ) assert result["type"] is FlowResultType.ABORT @@ -46,7 +54,15 @@ async def test_adding_second_device( new_callable=PropertyMock(return_value="secondary_device"), ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT + 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=USER_INPUT, ) assert result["type"] is FlowResultType.CREATE_ENTRY @@ -57,9 +73,15 @@ async def test_connection_error( """Test we show user form on Atag connection error.""" mock_connection(aioclient_mock, conn_error=True) result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_USER}, - data=USER_INPUT, + 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=USER_INPUT, ) assert result["type"] is FlowResultType.FORM @@ -73,9 +95,15 @@ async def test_unauthorized( """Test we show correct form when Unauthorized error is raised.""" mock_connection(aioclient_mock, authorized=False) result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_USER}, - data=USER_INPUT, + 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=USER_INPUT, ) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" @@ -88,9 +116,15 @@ async def test_full_flow_implementation( """Test registering an integration and finishing flow works.""" mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_USER}, - data=USER_INPUT, + 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=USER_INPUT, ) assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == UID