mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Do not probe linkplay device if another config entry already contains the host (#146305)
* Do not probe if config entry already contains the host * Add unit test * Use common fixture
This commit is contained in:
parent
d33080d79e
commit
560eeac457
@ -31,6 +31,9 @@ class LinkPlayConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle Zeroconf discovery."""
|
"""Handle Zeroconf discovery."""
|
||||||
|
|
||||||
|
# Do not probe the device if the host is already configured
|
||||||
|
self._async_abort_entries_match({CONF_HOST: discovery_info.host})
|
||||||
|
|
||||||
session: ClientSession = await async_get_client_session(self.hass)
|
session: ClientSession = await async_get_client_session(self.hass)
|
||||||
bridge: LinkPlayBridge | None = None
|
bridge: LinkPlayBridge | None = None
|
||||||
|
|
||||||
|
@ -220,3 +220,28 @@ async def test_user_flow_errors(
|
|||||||
CONF_HOST: HOST,
|
CONF_HOST: HOST,
|
||||||
}
|
}
|
||||||
assert result["result"].unique_id == UUID
|
assert result["result"].unique_id == UUID
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_linkplay_factory_bridge")
|
||||||
|
async def test_zeroconf_no_probe_existing_device(
|
||||||
|
hass: HomeAssistant, mock_linkplay_factory_bridge: AsyncMock
|
||||||
|
) -> None:
|
||||||
|
"""Test we do not probe the device is the host is already configured."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
data={CONF_HOST: HOST},
|
||||||
|
domain=DOMAIN,
|
||||||
|
title=NAME,
|
||||||
|
unique_id=UUID,
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN,
|
||||||
|
context={"source": SOURCE_ZEROCONF},
|
||||||
|
data=ZEROCONF_DISCOVERY,
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
assert len(mock_linkplay_factory_bridge.mock_calls) == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user