Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/samsungtv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def _async_abort_if_host_already_in_progress(self) -> None:

def is_matching(self, other_flow: Self) -> bool:
"""Return True if other_flow is matching this flow."""
return other_flow._host == self._host # noqa: SLF001
return getattr(other_flow, "_host", None) == self._host

@callback
def _abort_if_manufacturer_is_not_samsung(self) -> None:
Expand Down
36 changes: 36 additions & 0 deletions tests/components/samsungtv/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2143,3 +2143,39 @@ async def test_ssdp_update_mac(hass: HomeAssistant) -> None:
# ensure mac was updated with new wifiMac value
assert entry.data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
assert entry.unique_id == "123"


@pytest.mark.usefixtures("remote_websocket")
async def test_dhcp_while_user_flow_pending(hass: HomeAssistant) -> None:
"""Simulate pending user flow, then trigger DHCP before submit.

Covers https://github.com/home-assistant/core/issues/156591.
"""
with patch(
"homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info",
return_value=None, # Simulate device not connectable
):
# Start user flow, which will show form (cannot connect)
result_user = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result_user["type"] == FlowResultType.FORM
assert result_user["step_id"] == "user"

# While user flow is pending (form shown), trigger DHCP flow
dhcp_data = DhcpServiceInfo(
ip="10.10.12.34", macaddress="aabbccddeeff", hostname="fake_hostname"
)
with patch(
"homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info",
return_value={
"device": {"modelName": "fake_model", "wifiMac": "aa:bb:cc:dd:ee:ff"}
},
):
result_dhcp = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_DHCP},
data=dhcp_data,
)
assert result_dhcp["type"] == FlowResultType.ABORT
Loading