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 5
5
import pytest
6
6
import zigpy .application
7
7
import zigpy .device
8
+ from zigpy .device import Device
8
9
import zigpy .quirks
9
10
import zigpy .types
10
11
from zigpy .zcl import foundation
21
22
PROFILE_ID ,
22
23
)
23
24
25
+ from .async_mock import sentinel
26
+
24
27
25
28
class MockApp (zigpy .application .ControllerApplication ):
26
29
"""App Controller."""
@@ -204,6 +207,25 @@ def _dev(
204
207
return _dev
205
208
206
209
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
+
207
229
@pytest .fixture
208
230
def assert_signature_matches_quirk ():
209
231
"""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 14
14
import zigpy .endpoint
15
15
import zigpy .profiles
16
16
import zigpy .quirks as zq
17
- from zigpy .quirks import CustomDevice
17
+ from zigpy .quirks import CustomDevice , DeviceRegistry
18
18
from zigpy .quirks .v2 import QuirkBuilder
19
19
import zigpy .types
20
20
from zigpy .zcl import foundation
@@ -845,8 +845,9 @@ def check_for_duplicate_cluster_ids(clusters) -> None:
845
845
check_for_duplicate_cluster_ids (ep_data .get (OUTPUT_CLUSTERS , []))
846
846
847
847
848
- async def test_local_data_cluster (zigpy_device_from_v2_quirk ) -> None :
848
+ async def test_local_data_cluster (device_mock ) -> None :
849
849
"""Ensure reading attributes from a LocalDataCluster works as expected."""
850
+ registry = DeviceRegistry ()
850
851
851
852
class TestLocalCluster (zhaquirks .LocalDataCluster ):
852
853
"""Test cluster."""
@@ -856,11 +857,11 @@ class TestLocalCluster(zhaquirks.LocalDataCluster):
856
857
_VALID_ATTRIBUTES = [2 ]
857
858
858
859
(
859
- QuirkBuilder (" manufacturer-local-test" , " model" )
860
+ QuirkBuilder (device_mock . manufacturer , device_mock . model , registry = registry )
860
861
.adds (TestLocalCluster )
861
862
.add_to_registry ()
862
863
)
863
- device = zigpy_device_from_v2_quirk ( "manufacturer-local-test" , "model" )
864
+ device = registry . get_device ( device_mock )
864
865
assert isinstance (device .endpoints [1 ].in_clusters [0x1234 ], TestLocalCluster )
865
866
866
867
# reading invalid attribute return unsupported attribute
Original file line number Diff line number Diff line change 3
3
from unittest import mock
4
4
5
5
import pytest
6
- from zigpy .device import Device
7
6
from zigpy .quirks .registry import DeviceRegistry
8
7
from zigpy .quirks .v2 import CustomDeviceV2
9
8
import zigpy .types as t
25
24
)
26
25
from zhaquirks .tuya .mcu import TuyaMCUCluster , TuyaOnOffNM
27
26
28
- from .async_mock import sentinel
29
-
30
27
zhaquirks .setup ()
31
28
32
29
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
-
52
30
@pytest .mark .parametrize (
53
31
"method_name,attr_name,exp_class" ,
54
32
[
You can’t perform that action at this time.
0 commit comments