94
94
95
95
96
96
@pytest .mark .parametrize (
97
- "gateway_type, entity_type " ,
97
+ "gateway_type" ,
98
98
[
99
- ( "zha_gateway" , Platform . COVER ) ,
100
- ( "ws_gateway" , Platform . COVER ) ,
99
+ "zha_gateway" ,
100
+ "ws_gateway" ,
101
101
],
102
102
)
103
103
@pytest .mark .looptime
104
104
async def test_cover_non_tilt_initial_state ( # pylint: disable=unused-argument
105
105
zha_gateways : CombinedGateways ,
106
- zigpy_cover_device ,
107
106
gateway_type : str ,
108
- entity_type : type ,
109
107
) -> None :
110
108
"""Test ZHA cover platform."""
111
109
112
110
zha_gateway = getattr (zha_gateways , gateway_type )
111
+ zigpy_cover_device = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_DEVICE )
113
112
# load up cover domain
114
113
zigpy_cover_device = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_DEVICE )
115
114
cluster = zigpy_cover_device .endpoints [1 ].window_covering
@@ -164,17 +163,16 @@ async def test_cover_non_tilt_initial_state( # pylint: disable=unused-argument
164
163
165
164
166
165
@pytest .mark .parametrize (
167
- "gateway_type, entity_type " ,
166
+ "gateway_type" ,
168
167
[
169
- ( "zha_gateway" , Platform . COVER ) ,
170
- ( "ws_gateway" , Platform . COVER ) ,
168
+ "zha_gateway" ,
169
+ "ws_gateway" ,
171
170
],
172
171
)
173
172
@pytest .mark .looptime
174
173
async def test_cover (
175
174
zha_gateways : CombinedGateways ,
176
175
gateway_type : str ,
177
- entity_type : type ,
178
176
) -> None :
179
177
"""Test zha cover platform."""
180
178
@@ -410,21 +408,21 @@ async def test_cover(
410
408
411
409
412
410
@pytest .mark .parametrize (
413
- "gateway_type, entity_type " ,
411
+ "gateway_type" ,
414
412
[
415
- ( "zha_gateway" , Platform . COVER ) ,
416
- ( "ws_gateway" , Platform . COVER ) ,
413
+ "zha_gateway" ,
414
+ "ws_gateway" ,
417
415
],
418
416
)
419
417
@pytest .mark .looptime
420
418
async def test_cover_failures (
421
419
zha_gateways : CombinedGateways ,
422
420
gateway_type : str ,
423
- entity_type : type ,
424
421
) -> None :
425
422
"""Test ZHA cover platform failure cases."""
426
423
427
424
zha_gateway = getattr (zha_gateways , gateway_type )
425
+ zigpy_cover_device = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_DEVICE )
428
426
# load up cover domain
429
427
zigpy_cover_device = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_DEVICE )
430
428
cluster = zigpy_cover_device .endpoints [1 ].window_covering
@@ -621,17 +619,16 @@ async def test_cover_failures(
621
619
622
620
623
621
@pytest .mark .parametrize (
624
- "gateway_type, entity_type " ,
622
+ "gateway_type" ,
625
623
[
626
- ( "zha_gateway" , Platform . COVER ) ,
627
- ( "ws_gateway" , Platform . COVER ) ,
624
+ "zha_gateway" ,
625
+ "ws_gateway" ,
628
626
],
629
627
)
630
628
@pytest .mark .looptime
631
629
async def test_shade (
632
630
zha_gateways : CombinedGateways ,
633
631
gateway_type : str ,
634
- entity_type : type ,
635
632
) -> None :
636
633
"""Test zha cover platform for shade device type."""
637
634
@@ -813,17 +810,16 @@ async def test_shade(
813
810
814
811
815
812
@pytest .mark .parametrize (
816
- "gateway_type, entity_type " ,
813
+ "gateway_type" ,
817
814
[
818
- ( "zha_gateway" , Platform . COVER ) ,
819
- ( "ws_gateway" , Platform . COVER ) ,
815
+ "zha_gateway" ,
816
+ "ws_gateway" ,
820
817
],
821
818
)
822
819
@pytest .mark .looptime
823
820
async def test_keen_vent (
824
821
zha_gateways : CombinedGateways ,
825
822
gateway_type : str ,
826
- entity_type : type ,
827
823
) -> None :
828
824
"""Test keen vent."""
829
825
@@ -893,21 +889,21 @@ async def test_keen_vent(
893
889
894
890
895
891
@pytest .mark .parametrize (
896
- "gateway_type, entity_type " ,
892
+ "gateway_type" ,
897
893
[
898
- ( "zha_gateway" , Platform . COVER ) ,
899
- ( "ws_gateway" , Platform . COVER ) ,
894
+ "zha_gateway" ,
895
+ "ws_gateway" ,
900
896
],
901
897
)
902
898
@pytest .mark .looptime
903
899
async def test_cover_remote (
904
900
zha_gateways : CombinedGateways ,
905
901
gateway_type : str ,
906
- entity_type : type ,
907
902
) -> None :
908
903
"""Test ZHA cover remote."""
909
904
910
905
zha_gateway = getattr (zha_gateways , gateway_type )
906
+ zigpy_cover_remote = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_REMOTE )
911
907
# load up cover domain
912
908
zigpy_cover_remote = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_REMOTE )
913
909
zha_device = await join_zigpy_device (zha_gateway , zigpy_cover_remote )
@@ -946,12 +942,21 @@ async def test_cover_remote(
946
942
assert device .emit_zha_event .call_args [0 ][0 ][ATTR_COMMAND ] == "down_close"
947
943
948
944
949
- # TODO parametrize this test and add service to restore state attributes
945
+ @pytest .mark .parametrize (
946
+ "gateway_type" ,
947
+ [
948
+ "zha_gateway" ,
949
+ "ws_gateway" ,
950
+ ],
951
+ )
950
952
@pytest .mark .looptime
951
953
async def test_cover_state_restoration (
952
- zha_gateway : Gateway ,
954
+ zha_gateways : CombinedGateways ,
955
+ gateway_type : str ,
953
956
) -> None :
954
957
"""Test the cover state restoration."""
958
+
959
+ zha_gateway = getattr (zha_gateways , gateway_type )
955
960
zigpy_cover_device = create_mock_zigpy_device (zha_gateway , ZIGPY_COVER_DEVICE )
956
961
zha_device = await join_zigpy_device (zha_gateway , zigpy_cover_device )
957
962
entity = get_entity (zha_device , platform = Platform .COVER )
@@ -966,6 +971,11 @@ async def test_cover_state_restoration(
966
971
target_tilt_position = 34 ,
967
972
)
968
973
974
+ # ws impl needs a round trip to get the state back to the client
975
+ # maybe we make this optimistic, set the state manually on the client
976
+ # and avoid the round trip refresh call?
977
+ await zha_gateway .async_block_till_done ()
978
+
969
979
assert entity .state ["state" ] == STATE_CLOSED
970
980
assert entity .state ["target_lift_position" ] == 12
971
981
assert entity .state ["target_tilt_position" ] == 34
0 commit comments