Add broken link and missing device lists to insteon configuration panel (#119715)

* Add broken link and missing device lists

* Fix incorrect import

* Add tests

* Bump pyinsteon

* Typing
This commit is contained in:
Tom Harris 2024-09-20 06:11:51 -04:00 committed by GitHub
parent 90f691fa2c
commit 7433d2eca9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 245 additions and 23 deletions

View file

@ -1,5 +1,6 @@
"""Test the Insteon All-Link Database APIs."""
import asyncio
import json
from typing import Any
from unittest.mock import patch
@ -332,3 +333,38 @@ async def test_bad_address(
msg = await ws_client.receive_json()
assert not msg["success"]
assert msg["error"]["message"] == INSTEON_DEVICE_NOT_FOUND
async def test_notify_on_aldb_loading(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator, aldb_data
) -> None:
"""Test tracking changes to ALDB status across all devices."""
ws_client, devices = await _setup(hass, hass_ws_client, aldb_data)
with patch.object(insteon.api.aldb, "devices", devices):
await ws_client.send_json_auto_id({TYPE: "insteon/aldb/notify_all"})
msg = await ws_client.receive_json()
assert msg["success"]
await asyncio.sleep(0.1)
msg = await ws_client.receive_json()
assert msg["event"]["type"] == "status"
assert not msg["event"]["is_loading"]
device = devices["333333"]
device.aldb._update_status(ALDBStatus.LOADING)
await asyncio.sleep(0.1)
msg = await ws_client.receive_json()
assert msg["event"]["type"] == "status"
assert msg["event"]["is_loading"]
device.aldb._update_status(ALDBStatus.LOADED)
await asyncio.sleep(0.1)
msg = await ws_client.receive_json()
assert msg["event"]["type"] == "status"
assert not msg["event"]["is_loading"]
await ws_client.client.session.close()
# Allow lingering tasks to complete
await asyncio.sleep(0.1)