Skip to content

Commit

Permalink
Add test for user flow override discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-sl committed Feb 2, 2025
1 parent 453c5b1 commit 71edb4a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/components/smlight/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,44 @@ async def test_user_device_exists_abort(
assert result["reason"] == "already_configured"


@pytest.mark.usefixtures("mock_smlight_client")
async def test_user_flow_can_override_discovery(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_setup_entry: AsyncMock,
) -> None:
"""Test manual user flow can override discovery in progress."""

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=DISCOVERY_INFO
)

assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery"

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == SOURCE_USER
assert result["errors"] == {}

result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_HOST: MOCK_HOST,
},
)

assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["context"]["source"] == SOURCE_USER
assert result2["data"] == {
CONF_HOST: MOCK_HOST,
}
assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff"
assert len(mock_setup_entry.mock_calls) == 1


@pytest.mark.usefixtures("mock_smlight_client")
async def test_zeroconf_device_exists_abort(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
Expand Down

0 comments on commit 71edb4a

Please sign in to comment.