Skip to content

Commit

Permalink
Update test_config_flow.py
Browse files Browse the repository at this point in the history
  • Loading branch information
VandeurenGlenn committed Dec 25, 2024
1 parent 5cd0c81 commit cdb2d64
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/components/niko_home_control/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit cdb2d64

Please sign in to comment.