Skip to content

Commit 1110a5a

Browse files
committed
Mock discover attributes to list all
1 parent 48c5111 commit 1110a5a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ async def _read_attribute_raw(attributes: Any, *args: Any, **kwargs: Any) -> Any
4444
result.append(zcl_f.ReadAttributeRecord(attr_id, zcl_f.Status.FAILURE))
4545
return (result,)
4646

47+
async def _discover_attributes(*args: Any, **kwargs: Any) -> Any:
48+
schema = zcl_f.GENERAL_COMMANDS[
49+
zcl_f.GeneralCommand.Discover_Attributes_rsp
50+
].schema
51+
records = [
52+
zcl_f.DiscoverAttributesResponseRecord.from_dict(
53+
{"attrid": attr.id, "datatype": 0}
54+
)
55+
for attr in cluster.attributes.values()
56+
]
57+
return schema(discovery_complete=t.Bool.true, attribute_info=records)
58+
4759
cluster.bind = AsyncMock(return_value=[0])
4860
cluster.configure_reporting = AsyncMock(
4961
return_value=[
@@ -61,6 +73,7 @@ async def _read_attribute_raw(attributes: Any, *args: Any, **kwargs: Any) -> Any
6173
cluster._write_attributes = AsyncMock(
6274
return_value=[zcl_f.WriteAttributesResponse.deserialize(b"\x00")[0]]
6375
)
76+
cluster.discover_attributes = AsyncMock(side_effect=_discover_attributes)
6477
if cluster.cluster_id == 4:
6578
cluster.add = AsyncMock(return_value=[0])
6679
if cluster.cluster_id == 0x1000:

0 commit comments

Comments
 (0)