30
30
import chip .clusters as Clusters
31
31
from chip .clusters .Types import NullValue
32
32
from chip .interaction_model import InteractionModelError , Status
33
- from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
33
+ from matter_testing_support import MatterBaseTest , TestStep , default_matter_test_main , has_attribute , run_if_endpoint_matches
34
34
from mobly import asserts
35
35
36
36
@@ -56,96 +56,69 @@ def steps_TC_VALCC_3_3(self) -> list[TestStep]:
56
56
]
57
57
return steps
58
58
59
- def pics_TC_VALCC_3_3 (self ) -> list [str ]:
60
- pics = [
61
- "VALCC.S" ,
62
- ]
63
- return pics
64
-
65
- @async_test_body
59
+ @run_if_endpoint_matches (has_attribute (Clusters .ValveConfigurationAndControl .Attributes .DefaultOpenLevel ))
66
60
async def test_TC_VALCC_3_3 (self ):
67
61
68
- endpoint = self .user_params . get ( " endpoint" , 1 )
62
+ endpoint = self .matter_test_config . endpoint
69
63
70
64
self .step (1 )
71
65
attributes = Clusters .ValveConfigurationAndControl .Attributes
72
66
73
67
self .step (2 )
74
- attribute_list = await self . read_valcc_attribute_expect_success ( endpoint = endpoint , attribute = attributes . AttributeList )
68
+ # Done as part of the test initialization
75
69
76
70
self .step (3 )
77
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
78
- defaultOpenLevel = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .DefaultOpenLevel )
79
- else :
80
- logging .info ("Test step skipped" )
71
+ defaultOpenLevel = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .DefaultOpenLevel )
81
72
82
73
self .step (4 )
83
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
84
- try :
85
- await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Open (), endpoint = endpoint )
86
- except InteractionModelError as e :
87
- asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
88
- pass
89
- else :
90
- logging .info ("Test step skipped" )
74
+ try :
75
+ await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Open (), endpoint = endpoint )
76
+ except InteractionModelError as e :
77
+ asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
78
+ pass
91
79
92
80
self .step (5 )
93
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
94
- target_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetLevel )
81
+ target_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetLevel )
95
82
96
- asserts .assert_true (target_level_dut is not NullValue , "TargetLevel is null" )
97
- asserts .assert_equal (target_level_dut , defaultOpenLevel , "TargetLevel is not the expected value" )
98
- else :
99
- logging .info ("Test step skipped" )
83
+ asserts .assert_true (target_level_dut is not NullValue , "TargetLevel is null" )
84
+ asserts .assert_equal (target_level_dut , defaultOpenLevel , "TargetLevel is not the expected value" )
100
85
101
86
self .step (6 )
102
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
103
- current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
104
- asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
87
+ current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
88
+ asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
105
89
106
- while current_level_dut != defaultOpenLevel :
107
- time .sleep (1 )
90
+ while current_level_dut != defaultOpenLevel :
91
+ time .sleep (1 )
108
92
109
- current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
110
- asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
93
+ current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
94
+ asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
111
95
112
- asserts .assert_equal (current_level_dut , defaultOpenLevel , "CurrentLevel is not the expected value" )
113
- else :
114
- logging .info ("Test step skipped" )
96
+ asserts .assert_equal (current_level_dut , defaultOpenLevel , "CurrentLevel is not the expected value" )
115
97
116
98
self .step (7 )
117
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
118
- try :
119
- await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Close (), endpoint = endpoint )
120
- except InteractionModelError as e :
121
- asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
122
- pass
123
- else :
124
- logging .info ("Test step skipped" )
99
+ try :
100
+ await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Close (), endpoint = endpoint )
101
+ except InteractionModelError as e :
102
+ asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
103
+ pass
125
104
126
105
self .step (8 )
127
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
128
- target_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetLevel )
106
+ target_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetLevel )
129
107
130
- asserts .assert_true (target_level_dut is not NullValue , "TargetLevel is null" )
131
- asserts .assert_equal (target_level_dut , 0 , "TargetLevel is not the expected value" )
132
- else :
133
- logging .info ("Test step skipped" )
108
+ asserts .assert_true (target_level_dut is not NullValue , "TargetLevel is null" )
109
+ asserts .assert_equal (target_level_dut , 0 , "TargetLevel is not the expected value" )
134
110
135
111
self .step (9 )
136
- if attributes .DefaultOpenLevel .attribute_id in attribute_list :
137
- current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
138
- asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
112
+ current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
113
+ asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
139
114
140
- while current_level_dut is Clusters .Objects .ValveConfigurationAndControl .Enums .ValveStateEnum .kTransitioning :
141
- time .sleep (1 )
115
+ while current_level_dut is Clusters .Objects .ValveConfigurationAndControl .Enums .ValveStateEnum .kTransitioning :
116
+ time .sleep (1 )
142
117
143
- current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
144
- asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
118
+ current_level_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentLevel )
119
+ asserts .assert_true (current_level_dut is not NullValue , "CurrentLevel is null" )
145
120
146
- asserts .assert_equal (current_level_dut , 0 , "CurrentLevel is not the expected value" )
147
- else :
148
- logging .info ("Test step skipped" )
121
+ asserts .assert_equal (current_level_dut , 0 , "CurrentLevel is not the expected value" )
149
122
150
123
151
124
if __name__ == "__main__" :
0 commit comments