File tree Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Original file line number Diff line number Diff line change 55import pytest
66import zigpy .application
77import zigpy .device
8+ from zigpy .device import Device
89import zigpy .quirks
910import zigpy .types
1011from zigpy .zcl import foundation
2122 PROFILE_ID ,
2223)
2324
25+ from .async_mock import sentinel
26+
2427
2528class MockApp (zigpy .application .ControllerApplication ):
2629 """App Controller."""
@@ -204,6 +207,25 @@ def _dev(
204207 return _dev
205208
206209
210+ @pytest .fixture (name = "device_mock" )
211+ def real_device (MockAppController ):
212+ """Device fixture with a single endpoint."""
213+ ieee = sentinel .ieee
214+ nwk = 0x2233
215+ device = Device (MockAppController , ieee , nwk )
216+
217+ device .add_endpoint (1 )
218+ device [1 ].profile_id = 0x0104
219+ device [1 ].device_type = 0x0051
220+ device .model = "model"
221+ device .manufacturer = "manufacturer"
222+ device [1 ].add_input_cluster (0x0000 )
223+ device [1 ].add_input_cluster (0xEF00 )
224+ device [1 ].add_output_cluster (0x000A )
225+ device [1 ].add_output_cluster (0x0019 )
226+ return device
227+
228+
207229@pytest .fixture
208230def assert_signature_matches_quirk ():
209231 """Return a function that can be used to check if a given quirk matches a signature."""
Original file line number Diff line number Diff line change 1414import zigpy .endpoint
1515import zigpy .profiles
1616import zigpy .quirks as zq
17- from zigpy .quirks import CustomDevice
17+ from zigpy .quirks import CustomDevice , DeviceRegistry
1818from zigpy .quirks .v2 import QuirkBuilder
1919import zigpy .types
2020from zigpy .zcl import foundation
@@ -845,8 +845,9 @@ def check_for_duplicate_cluster_ids(clusters) -> None:
845845 check_for_duplicate_cluster_ids (ep_data .get (OUTPUT_CLUSTERS , []))
846846
847847
848- async def test_local_data_cluster (zigpy_device_from_v2_quirk ) -> None :
848+ async def test_local_data_cluster (device_mock ) -> None :
849849 """Ensure reading attributes from a LocalDataCluster works as expected."""
850+ registry = DeviceRegistry ()
850851
851852 class TestLocalCluster (zhaquirks .LocalDataCluster ):
852853 """Test cluster."""
@@ -856,11 +857,11 @@ class TestLocalCluster(zhaquirks.LocalDataCluster):
856857 _VALID_ATTRIBUTES = [2 ]
857858
858859 (
859- QuirkBuilder (" manufacturer-local-test" , " model" )
860+ QuirkBuilder (device_mock . manufacturer , device_mock . model , registry = registry )
860861 .adds (TestLocalCluster )
861862 .add_to_registry ()
862863 )
863- device = zigpy_device_from_v2_quirk ( "manufacturer-local-test" , "model" )
864+ device = registry . get_device ( device_mock )
864865 assert isinstance (device .endpoints [1 ].in_clusters [0x1234 ], TestLocalCluster )
865866
866867 # reading invalid attribute return unsupported attribute
Original file line number Diff line number Diff line change 33from unittest import mock
44
55import pytest
6- from zigpy .device import Device
76from zigpy .quirks .registry import DeviceRegistry
87from zigpy .quirks .v2 import CustomDeviceV2
98import zigpy .types as t
2524)
2625from zhaquirks .tuya .mcu import TuyaMCUCluster , TuyaOnOffNM
2726
28- from .async_mock import sentinel
29-
3027zhaquirks .setup ()
3128
3229
33- @pytest .fixture (name = "device_mock" )
34- def real_device (MockAppController ):
35- """Device fixture with a single endpoint."""
36- ieee = sentinel .ieee
37- nwk = 0x2233
38- device = Device (MockAppController , ieee , nwk )
39-
40- device .add_endpoint (1 )
41- device [1 ].profile_id = 0x0104
42- device [1 ].device_type = 0x0051
43- device .model = "model"
44- device .manufacturer = "manufacturer"
45- device [1 ].add_input_cluster (0x0000 )
46- device [1 ].add_input_cluster (0xEF00 )
47- device [1 ].add_output_cluster (0x000A )
48- device [1 ].add_output_cluster (0x0019 )
49- return device
50-
51-
5230@pytest .mark .parametrize (
5331 "method_name,attr_name,exp_class" ,
5432 [
You can’t perform that action at this time.
0 commit comments