16
16
#
17
17
18
18
import logging
19
- import time
20
19
21
20
import chip .clusters as Clusters
22
21
from chip .interaction_model import Status
23
- from matter_testing_support import MatterBaseTest , async_test_body , default_matter_test_main
22
+ from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
24
23
from mobly import asserts
25
24
26
25
logger = logging .getLogger (__name__ )
@@ -42,50 +41,96 @@ async def write_rock_setting(self, endpoint, rock_setting):
42
41
result = await self .default_controller .WriteAttribute (self .dut_node_id , [(endpoint , Clusters .FanControl .Attributes .RockSetting (rock_setting ))])
43
42
asserts .assert_equal (result [0 ].Status , Status .Success , "RockSetting write failed" )
44
43
44
+ async def write_rock_setting_expect_failure (self , endpoint , rock_setting ):
45
+ result = await self .default_controller .WriteAttribute (self .dut_node_id , [(endpoint , Clusters .FanControl .Attributes .RockSetting (rock_setting ))])
46
+ asserts .assert_equal (result [0 ].Status , Status .ConstraintError , "Expected ConstraintError but received a different error." )
47
+
48
+ def desc_TC_FAN_3_3 (self ) -> str :
49
+ return "[TC-FAN-3.3] Optional rock functionality with DUT as Server"
50
+
51
+ def steps_TC_FAN_3_3 (self ) -> list [TestStep ]:
52
+ steps = [
53
+ TestStep (1 , "Commissioning, already done" , is_commissioning = True ),
54
+ TestStep (2 , "Read from the DUT the RockSupport attribute and store" ),
55
+ TestStep (3 , "RockLeftRight is supported, so write 0x01 to RockSetting" ),
56
+ TestStep (4 , "Read from the DUT the RockSetting attribute" ),
57
+ TestStep (5 , "RockLeftRight is not supported, so write 0x01 to RockSetting to check for constraint error" ),
58
+ TestStep (6 , "RockUpDown is supported, so write 0x02 to RockSetting" ),
59
+ TestStep (7 , "Read from the DUT the RockSetting attribute" ),
60
+ TestStep (8 , "RockUpDown is not supported, so write 0x02 to RockSetting to check for constraint error" ),
61
+ TestStep (9 , "RockRound is supported, so write 0x04 to RockSetting" ),
62
+ TestStep (10 , "Read from the DUT the RockSetting attribute" ),
63
+ TestStep (11 , "RockRound is not supported, so write 0x04 to RockSetting to check for constraint error" ),
64
+ TestStep (12 , "Write RockSetting to 0x00" ),
65
+ ]
66
+ return steps
67
+
45
68
def pics_TC_FAN_3_3 (self ) -> list [str ]:
46
69
return ["FAN.S" ]
47
70
48
71
@async_test_body
49
72
async def test_TC_FAN_3_3 (self ):
50
73
if not self .check_pics ("FAN.S.F02" ):
51
74
logger .info ("Test skipped because PICS FAN.S.F02 is not set" )
75
+ self .skip_all_remaining_steps (1 )
52
76
return
53
77
54
78
endpoint = self .user_params .get ("endpoint" , 1 )
55
79
56
- self .print_step ( 1 , "Commissioning, already done" )
80
+ self .step ( 1 )
57
81
58
- self .print_step ( 2 , "Read from the DUT the RockSupport attribute and store" )
82
+ self .step ( 2 )
59
83
rock_support = await self .read_rock_support (endpoint = endpoint )
60
84
61
85
if rock_support & Clusters .FanControl .Bitmaps .RockBitmap .kRockLeftRight :
62
- self .print_step ( 3 , "RockLeftRight is supported, so write 0x01 to RockSetting" )
86
+ self .step ( 3 )
63
87
await self .write_rock_setting (endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockLeftRight )
64
- time .sleep (1 )
65
88
66
- self .print_step ( 4 , "Read from the DUT the RockSetting attribute" )
89
+ self .step ( 4 )
67
90
rock_setting = await self .read_rock_setting (endpoint = endpoint )
68
91
asserts .assert_equal (rock_setting , Clusters .FanControl .Bitmaps .RockBitmap .kRockLeftRight , "RockSetting is not 0x01" )
69
92
93
+ self .skip_step (5 )
94
+ else :
95
+ self .skip_step (3 )
96
+ self .skip_step (4 )
97
+
98
+ self .step (5 )
99
+ self .write_rock_setting_expect_failure (
100
+ endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockLeftRight )
101
+
70
102
if rock_support & Clusters .FanControl .Bitmaps .RockBitmap .kRockUpDown :
71
- self .print_step ( 5 , "RockUpDown is supported, so write 0x02 to RockSetting" )
103
+ self .step ( 6 )
72
104
await self .write_rock_setting (endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockUpDown )
73
- time .sleep (1 )
74
105
75
- self .print_step ( 6 , "Read from the DUT the RockSetting attribute" )
106
+ self .step ( 7 )
76
107
rock_setting = await self .read_rock_setting (endpoint = endpoint )
77
108
asserts .assert_equal (rock_setting , Clusters .FanControl .Bitmaps .RockBitmap .kRockUpDown , "RockSetting is not 0x02" )
78
109
110
+ self .skip_step (8 )
111
+ else :
112
+ self .skip_step (6 )
113
+ self .skip_step (7 )
114
+
115
+ self .step (8 )
116
+ await self .write_rock_setting_expect_failure (endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockUpDown )
117
+
79
118
if rock_support & Clusters .FanControl .Bitmaps .RockBitmap .kRockRound :
80
- self .print_step ( 7 , "RockRound is supported, so write 0x04 to RockSetting" )
119
+ self .step ( 9 )
81
120
await self .write_rock_setting (endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockRound )
82
- time .sleep (1 )
83
121
84
- self .print_step ( 8 , "Read from the DUT the RockSetting attribute" )
122
+ self .step ( 10 )
85
123
rock_setting = await self .read_rock_setting (endpoint = endpoint )
86
124
asserts .assert_equal (rock_setting , Clusters .FanControl .Bitmaps .RockBitmap .kRockRound , "RockSetting is not 0x04" )
125
+ self .skip_step (11 )
126
+ else :
127
+ self .skip_step (9 )
128
+ self .skip_step (10 )
129
+
130
+ self .step (11 )
131
+ await self .write_rock_setting_expect_failure (endpoint = endpoint , rock_setting = Clusters .FanControl .Bitmaps .RockBitmap .kRockRound )
87
132
88
- self .print_step ( 9 , "Write RockSetting to 0x00" )
133
+ self .step ( 12 )
89
134
await self .write_rock_setting (endpoint = endpoint , rock_setting = 0x00 )
90
135
91
136
0 commit comments