mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add missing None-check in roomba config flow (#127212)
This commit is contained in:
parent
e2518ab4d7
commit
95a79130a2
@ -130,7 +130,9 @@ class RoombaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
# going for a longer hostname we abort so the user
|
||||
# does not see two flows if discovery fails.
|
||||
for progress in self._async_in_progress():
|
||||
flow_unique_id: str = progress["context"]["unique_id"]
|
||||
flow_unique_id = progress["context"].get("unique_id")
|
||||
if not flow_unique_id:
|
||||
continue
|
||||
if flow_unique_id.startswith(self.blid):
|
||||
return self.async_abort(reason="short_blid")
|
||||
if self.blid.startswith(flow_unique_id):
|
||||
|
@ -1055,6 +1055,43 @@ async def test_dhcp_discovery_partial_hostname(hass: HomeAssistant) -> None:
|
||||
assert current_flows[0]["flow_id"] == result2["flow_id"]
|
||||
|
||||
|
||||
async def test_dhcp_discovery_when_user_flow_in_progress(hass: HomeAssistant) -> None:
|
||||
"""Test discovery flow when user flow is in progress."""
|
||||
|
||||
# Start a DHCP flow
|
||||
with patch(
|
||||
"homeassistant.components.roomba.config_flow.RoombaDiscovery", _mocked_discovery
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Start a user flow - unique ID not set
|
||||
with patch(
|
||||
"homeassistant.components.roomba.config_flow.RoombaDiscovery", _mocked_discovery
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip=MOCK_IP,
|
||||
macaddress="aabbccddeeff",
|
||||
hostname="irobot-blidthatislonger",
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "link"
|
||||
|
||||
current_flows = hass.config_entries.flow.async_progress()
|
||||
assert len(current_flows) == 2
|
||||
|
||||
|
||||
async def test_options_flow(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user