From 91e8c7a81b77c5986400bacba5ceecf519ab3e73 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 30 Aug 2026 12:21:06 +0200 Subject: [PATCH] Split the Dune HD user flow init from its data (#180750) --- tests/components/dunehd/test_config_flow.py | 62 ++++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/tests/components/dunehd/test_config_flow.py b/tests/components/dunehd/test_config_flow.py index a35c1eec4cca..246eb15b1f60 100644 --- a/tests/components/dunehd/test_config_flow.py +++ b/tests/components/dunehd/test_config_flow.py @@ -19,7 +19,15 @@ DUNEHD_STATE = {"protocol_version": "4", "player_state": "navigator"} async def test_user_invalid_host(hass: HomeAssistant) -> None: """Test that errors are shown when the host is invalid.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "invalid/host"} + 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: "invalid/host"}, ) assert result["errors"] == {CONF_HOST: "invalid_host"} @@ -34,7 +42,15 @@ async def test_user_very_long_host(hass: HomeAssistant) -> None: "host_very_long_host_very_long_host" ) result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: long_host} + 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: long_host}, ) assert result["errors"] == {CONF_HOST: "invalid_host"} @@ -44,7 +60,15 @@ async def test_user_cannot_connect(hass: HomeAssistant) -> None: """Test that errors are shown when cannot connect to the host.""" with patch("pdunehd.DuneHDPlayer.update_state", return_value={}): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_IP + 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=CONFIG_IP, ) assert result["errors"] == {CONF_HOST: "cannot_connect"} @@ -61,7 +85,15 @@ async def test_duplicate_error(hass: HomeAssistant) -> None: with patch("pdunehd.DuneHDPlayer.update_state", return_value=DUNEHD_STATE): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_HOSTNAME + 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=CONFIG_HOSTNAME, ) assert result["errors"] == {CONF_HOST: "already_configured"} @@ -74,7 +106,15 @@ async def test_create_entry(hass: HomeAssistant) -> None: patch("pdunehd.DuneHDPlayer.update_state", return_value=DUNEHD_STATE), ): result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_HOSTNAME + 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=CONFIG_HOSTNAME, ) assert result["type"] is FlowResultType.CREATE_ENTRY @@ -89,9 +129,15 @@ async def test_create_entry_with_ipv6_address(hass: HomeAssistant) -> None: patch("pdunehd.DuneHDPlayer.update_state", return_value=DUNEHD_STATE), ): result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_USER}, - data={CONF_HOST: "2001:db8::1428:57ab"}, + 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: "2001:db8::1428:57ab"}, ) assert result["type"] is FlowResultType.CREATE_ENTRY