Add auto device removal handling to Whisker (#165709)

This commit is contained in:
Nathan Spencer
2026-03-16 18:01:37 +00:00
committed by GitHub
parent bf23fc5887
commit 00b0da7d26
3 changed files with 31 additions and 9 deletions
+12 -3
View File
@@ -256,12 +256,12 @@ async def test_dynamic_devices(
device_registry: dr.DeviceRegistry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test new device found."""
"""Test dynamic addition of new devices and removal of stale devices."""
delta_time = timedelta(seconds=305) # 5 minutes + 5 delta seconds
entry = await setup_integration(hass, mock_account)
# First check -> there is 1 device in total
# First check -> 1 device created
assert len(dr.async_entries_for_config_entry(device_registry, entry.entry_id)) == 1
mock_account.robots.extend([LitterRobot4(data=ROBOT_4_DATA, account=mock_account)])
@@ -270,5 +270,14 @@ async def test_dynamic_devices(
async_fire_time_changed(hass)
await hass.async_block_till_done()
# Second check -> added one device
# Second check -> added 1 device
assert len(dr.async_entries_for_config_entry(device_registry, entry.entry_id)) == 2
mock_account.robots.pop(0)
freezer.tick(delta_time)
async_fire_time_changed(hass)
await hass.async_block_till_done()
# Third check -> removed 1 device
assert len(dr.async_entries_for_config_entry(device_registry, entry.entry_id)) == 1