1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Fix is_matching in samsungtv config flow (#156594)

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Fredrik Mårtensson
2025-11-18 16:12:21 +01:00
committed by GitHub
parent a13cdbdf3d
commit 291331f878
2 changed files with 37 additions and 1 deletions

View File

@@ -441,7 +441,7 @@ class SamsungTVConfigFlow(ConfigFlow, domain=DOMAIN):
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:

View File

@@ -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