Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,34 @@ def zigpy_device_from_device_data(
device = quirks_get_device(device)

for epid, ep in device_data["endpoints"].items():
endpoint = device.endpoints[int(epid)]
try:
endpoint = device.endpoints[int(epid)]
except KeyError:
_LOGGER.warning(
"Endpoint %d not found on device %s",
int(epid),
device,
)
continue

endpoint.request = AsyncMock(return_value=[0])

for cluster_type in ("in_clusters", "out_clusters"):
clusters = getattr(endpoint, cluster_type)

for cluster in ep[cluster_type]:
real_cluster = getattr(endpoint, cluster_type)[
int(cluster["cluster_id"], 16)
]
cluster_id = int(cluster["cluster_id"], 16)

try:
real_cluster = clusters[cluster_id]
except KeyError:
_LOGGER.warning(
"Cluster %0#04x not found on endpoint %r of device %s",
cluster_id,
endpoint,
device,
)
continue

if patch_cluster:
patch_cluster_for_testing(real_cluster)
Expand Down
Loading
Loading