From a3a138e8e0c473a6903d46b755ca806cccb58e70 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 30 Aug 2026 12:18:53 +0200 Subject: [PATCH] Split the Iskra user flow init from its data (#180741) --- tests/components/iskra/test_config_flow.py | 48 ++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/components/iskra/test_config_flow.py b/tests/components/iskra/test_config_flow.py index 7bc438e44c3e..4d78e6b5970e 100644 --- a/tests/components/iskra/test_config_flow.py +++ b/tests/components/iskra/test_config_flow.py @@ -171,9 +171,15 @@ async def test_modbus_abort_if_already_setup( MockConfigEntry(domain=DOMAIN, unique_id=SERIAL).add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_USER}, - data={CONF_HOST: HOST, CONF_PROTOCOL: "modbus_tcp"}, + DOMAIN, context={"source": 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={CONF_HOST: HOST, CONF_PROTOCOL: "modbus_tcp"}, ) assert result["type"] is FlowResultType.FORM @@ -197,9 +203,15 @@ async def test_rest_api_abort_if_already_setup( MockConfigEntry(domain=DOMAIN, unique_id=SERIAL).add_to_hass(hass) result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_USER}, - data={CONF_HOST: HOST, CONF_PROTOCOL: "rest_api"}, + DOMAIN, context={"source": 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={CONF_HOST: HOST, CONF_PROTOCOL: "rest_api"}, ) assert result["type"] is FlowResultType.ABORT @@ -225,9 +237,15 @@ async def test_modbus_device_error( mock_pyiskra_modbus.side_effect = s_effect result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_USER}, - data={CONF_HOST: HOST, CONF_PROTOCOL: "modbus_tcp"}, + DOMAIN, context={"source": 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={CONF_HOST: HOST, CONF_PROTOCOL: "modbus_tcp"}, ) assert result["type"] is FlowResultType.FORM @@ -287,9 +305,15 @@ async def test_rest_device_error( mock_pyiskra_rest.side_effect = s_effect result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_USER}, - data={CONF_HOST: HOST, CONF_PROTOCOL: "rest_api"}, + DOMAIN, context={"source": 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={CONF_HOST: HOST, CONF_PROTOCOL: "rest_api"}, ) # Test if error returned