UniFi Protect cleanup and enable unadopted devices (#73860)

This commit is contained in:
Christopher Bailey 2022-06-22 16:57:21 -04:00 committed by GitHub
parent 5c5fd746fd
commit 01a9367281
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 258 additions and 114 deletions

View file

@ -242,3 +242,27 @@ async def test_device_remove_devices(
await remove_device(await hass_ws_client(hass), dead_device_entry.id, entry_id)
is True
)
async def test_device_remove_devices_nvr(
hass: HomeAssistant,
mock_entry: MockEntityFixture,
hass_ws_client: Callable[
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
],
) -> None:
"""Test we can only remove a NVR device that no longer exists."""
assert await async_setup_component(hass, "config", {})
mock_entry.api.get_bootstrap = AsyncMock(return_value=mock_entry.api.bootstrap)
await hass.config_entries.async_setup(mock_entry.entry.entry_id)
await hass.async_block_till_done()
entry_id = mock_entry.entry.entry_id
device_registry = dr.async_get(hass)
live_device_entry = list(device_registry.devices.values())[0]
assert (
await remove_device(await hass_ws_client(hass), live_device_entry.id, entry_id)
is False
)