From 7210c3588ed8fad54c9cd2610eef543521413f90 Mon Sep 17 00:00:00 2001 From: "Glenn Vandeuren (aka Iondependent)" Date: Wed, 25 Dec 2024 16:06:08 +0100 Subject: [PATCH] Update test_config_flow.py --- .../niko_home_control/test_config_flow.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/components/niko_home_control/test_config_flow.py b/tests/components/niko_home_control/test_config_flow.py index a22503e0d8b4b7..a79c164467a4da 100644 --- a/tests/components/niko_home_control/test_config_flow.py +++ b/tests/components/niko_home_control/test_config_flow.py @@ -184,3 +184,29 @@ async def test_reconfigure( ) await hass.async_block_till_done() assert result["type"] is FlowResultType.CREATE_ENTRY + + +async def test_cannot_connect_after_reconfigure( + hass: HomeAssistant, + mock_setup_entry: AsyncMock, + mock_config_entry: MockConfigEntry, +) -> None: + """Test the cannot connect error.""" + mock_config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + result = await mock_config_entry.start_reconfigure_flow(hass) + + assert result["type"] is FlowResultType.FORM + assert result["errors"] == {} + + with patch( + "homeassistant.components.niko_home_control.config_flow.NHCController.connect", + side_effect=Exception, + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_HOST: "192.168.0.122"}, + ) + assert result["errors"] == {"base": "cannot_connect"}