mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Allow ignored idasen_desk devices to be set up from the user flow (#137253)
This commit is contained in:
parent
455af9179b
commit
1e1069b647
@ -87,7 +87,7 @@ class IdasenDeskConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
if discovery := self._discovery_info:
|
if discovery := self._discovery_info:
|
||||||
self._discovered_devices[discovery.address] = discovery
|
self._discovered_devices[discovery.address] = discovery
|
||||||
else:
|
else:
|
||||||
current_addresses = self._async_current_ids()
|
current_addresses = self._async_current_ids(include_ignore=False)
|
||||||
for discovery in async_discovered_service_info(self.hass):
|
for discovery in async_discovered_service_info(self.hass):
|
||||||
if (
|
if (
|
||||||
discovery.address in current_addresses
|
discovery.address in current_addresses
|
||||||
|
@ -50,6 +50,49 @@ async def test_user_step_success(hass: HomeAssistant, mock_desk_api: MagicMock)
|
|||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
async def test_user_step_replaces_ignored_device(
|
||||||
|
hass: HomeAssistant, mock_desk_api: MagicMock
|
||||||
|
) -> None:
|
||||||
|
"""Test user step replaces ignored devices."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
unique_id=IDASEN_DISCOVERY_INFO.address,
|
||||||
|
source=config_entries.SOURCE_IGNORE,
|
||||||
|
data={CONF_ADDRESS: IDASEN_DISCOVERY_INFO.address},
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.idasen_desk.config_flow.async_discovered_service_info",
|
||||||
|
return_value=[NOT_IDASEN_DISCOVERY_INFO, IDASEN_DISCOVERY_INFO],
|
||||||
|
):
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "user"
|
||||||
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.idasen_desk.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"],
|
||||||
|
{
|
||||||
|
CONF_ADDRESS: IDASEN_DISCOVERY_INFO.address,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
assert result2["title"] == IDASEN_DISCOVERY_INFO.name
|
||||||
|
assert result2["data"] == {
|
||||||
|
CONF_ADDRESS: IDASEN_DISCOVERY_INFO.address,
|
||||||
|
}
|
||||||
|
assert result2["result"].unique_id == IDASEN_DISCOVERY_INFO.address
|
||||||
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_user_step_no_devices_found(hass: HomeAssistant) -> None:
|
async def test_user_step_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
"""Test user step with no devices found."""
|
"""Test user step with no devices found."""
|
||||||
with patch(
|
with patch(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user