From f008a3ab146a3c7214efb8e5e4f46bb1a7f57e1b Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 29 Aug 2026 20:51:43 +0200 Subject: [PATCH] Split the Syncthing user flow init from its data (#180662) --- .../components/syncthing/test_config_flow.py | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/tests/components/syncthing/test_config_flow.py b/tests/components/syncthing/test_config_flow.py index b3d1c5c0f20e..9339c1315634 100644 --- a/tests/components/syncthing/test_config_flow.py +++ b/tests/components/syncthing/test_config_flow.py @@ -36,9 +36,14 @@ async def test_flow_successful(hass: HomeAssistant) -> None: ) as mock_setup_entry, ): result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": "user"}, - data=MOCK_ENTRY, + DOMAIN, context={"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=MOCK_ENTRY ) assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == URL @@ -54,9 +59,14 @@ async def test_flow_already_configured( """Test the server ID is already configured.""" with patch("aiosyncthing.system.System.status", return_value={"myID": SERVER_ID}): result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": "user"}, - data=MOCK_ENTRY, + DOMAIN, context={"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=MOCK_ENTRY ) assert result["type"] is FlowResultType.ABORT @@ -68,9 +78,14 @@ async def test_flow_invalid_auth(hass: HomeAssistant) -> None: with patch("aiosyncthing.system.System.status", side_effect=UnauthorizedError): result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": "user"}, - data=MOCK_ENTRY, + DOMAIN, context={"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=MOCK_ENTRY ) assert result["type"] is FlowResultType.FORM @@ -82,9 +97,14 @@ async def test_flow_cannot_connect(hass: HomeAssistant) -> None: with patch("aiosyncthing.system.System.status", side_effect=Exception): result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": "user"}, - data=MOCK_ENTRY, + DOMAIN, context={"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=MOCK_ENTRY ) assert result["type"] is FlowResultType.FORM