Skip to content

Commit 04e1632

Browse files
committed
VALCC: Remove top-level PICS
Self-select the valve tests off the device information rather than the PICS. This makes it easier to run the tests since you can just run them all unconditionally and they will run if required.
1 parent f509f67 commit 04e1632

10 files changed

+100
-250
lines changed

src/python_testing/TC_VALCC_2_1.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import chip.clusters as Clusters
3030
from chip.clusters.Types import NullValue
31-
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
31+
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, run_if_endpoint_matches, has_cluster
3232
from mobly import asserts
3333

3434

@@ -58,16 +58,10 @@ def steps_TC_VALCC_2_1(self) -> list[TestStep]:
5858
]
5959
return steps
6060

61-
def pics_TC_VALCC_2_1(self) -> list[str]:
62-
pics = [
63-
"VALCC.S",
64-
]
65-
return pics
66-
67-
@async_test_body
61+
@run_if_endpoint_matches(has_cluster(Clusters.ValveConfigurationAndControl))
6862
async def test_TC_VALCC_2_1(self):
6963

70-
endpoint = self.user_params.get("endpoint", 1)
64+
endpoint = self.matter_test_config.endpoint
7165

7266
self.step(1)
7367
attributes = Clusters.ValveConfigurationAndControl.Attributes

src/python_testing/TC_VALCC_3_1.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import chip.clusters as Clusters
3030
from chip.clusters.Types import NullValue
3131
from chip.interaction_model import InteractionModelError, Status
32-
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
32+
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, run_if_endpoint_matches, has_cluster
3333
from mobly import asserts
3434

3535

@@ -53,16 +53,10 @@ def steps_TC_VALCC_3_1(self) -> list[TestStep]:
5353
]
5454
return steps
5555

56-
def pics_TC_VALCC_3_1(self) -> list[str]:
57-
pics = [
58-
"VALCC.S",
59-
]
60-
return pics
61-
62-
@async_test_body
56+
@run_if_endpoint_matches(has_cluster(Clusters.ValveConfigurationAndControl))
6357
async def test_TC_VALCC_3_1(self):
6458

65-
endpoint = self.user_params.get("endpoint", 1)
59+
endpoint = self.matter_test_config.endpoint
6660

6761
self.step(1)
6862
attributes = Clusters.ValveConfigurationAndControl.Attributes

src/python_testing/TC_VALCC_3_2.py

+34-60
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import chip.clusters as Clusters
3131
from chip.clusters.Types import NullValue
3232
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, run_if_endpoint_matches, has_feature
3434
from mobly import asserts
3535

3636

@@ -55,92 +55,66 @@ def steps_TC_VALCC_3_2(self) -> list[TestStep]:
5555
]
5656
return steps
5757

58-
def pics_TC_VALCC_3_2(self) -> list[str]:
59-
pics = [
60-
"VALCC.S",
61-
]
62-
return pics
63-
64-
@async_test_body
58+
@run_if_endpoint_matches(has_feature(Clusters.ValveConfigurationAndControl, Clusters.ValveConfigurationAndControl.Bitmaps.Feature.kLevel))
6559
async def test_TC_VALCC_3_2(self):
6660

67-
endpoint = self.user_params.get("endpoint", 1)
61+
endpoint = self.matter_test_config.endpoint
6862

6963
self.step(1)
7064
attributes = Clusters.ValveConfigurationAndControl.Attributes
7165

7266
self.step(2)
73-
feature_map = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap)
74-
75-
is_lvl_feature_supported = feature_map & Clusters.ValveConfigurationAndControl.Bitmaps.Feature.kLevel
67+
# Done as part of the test initialization
7668

7769
self.step(3)
78-
if is_lvl_feature_supported:
79-
try:
80-
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(targetLevel=100), endpoint=endpoint)
81-
except InteractionModelError as e:
82-
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
83-
pass
84-
else:
85-
logging.info("Test step skipped")
70+
try:
71+
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Open(targetLevel=100), endpoint=endpoint)
72+
except InteractionModelError as e:
73+
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
74+
pass
8675

8776
self.step(4)
88-
if is_lvl_feature_supported:
89-
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
77+
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
9078

91-
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
92-
asserts.assert_equal(target_level_dut, 100, "TargetLevel is not the expected value")
93-
else:
94-
logging.info("Test step skipped")
79+
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
80+
asserts.assert_equal(target_level_dut, 100, "TargetLevel is not the expected value")
9581

9682
self.step(5)
97-
if is_lvl_feature_supported:
98-
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
99-
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
83+
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
84+
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
10085

101-
while current_level_dut != 100:
102-
time.sleep(1)
86+
while current_level_dut != 100:
87+
time.sleep(1)
10388

104-
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
105-
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
89+
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
90+
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
10691

107-
asserts.assert_equal(current_level_dut, 100, "CurrentLevel is not the expected value")
108-
else:
109-
logging.info("Test step skipped")
92+
asserts.assert_equal(current_level_dut, 100, "CurrentLevel is not the expected value")
11093

11194
self.step(6)
112-
if is_lvl_feature_supported:
113-
try:
114-
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
115-
except InteractionModelError as e:
116-
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
117-
pass
118-
else:
119-
logging.info("Test step skipped")
95+
try:
96+
await self.send_single_cmd(cmd=Clusters.Objects.ValveConfigurationAndControl.Commands.Close(), endpoint=endpoint)
97+
except InteractionModelError as e:
98+
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
99+
pass
120100

121101
self.step(7)
122-
if is_lvl_feature_supported:
123-
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
102+
target_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.TargetLevel)
124103

125-
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
126-
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")
127-
else:
128-
logging.info("Test step skipped")
104+
asserts.assert_true(target_level_dut is not NullValue, "TargetLevel is null")
105+
asserts.assert_equal(target_level_dut, 0, "TargetLevel is not the expected value")
129106

130107
self.step(8)
131-
if is_lvl_feature_supported:
132-
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
133-
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
108+
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
109+
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
134110

135-
while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
136-
time.sleep(1)
111+
while current_level_dut is Clusters.Objects.ValveConfigurationAndControl.Enums.ValveStateEnum.kTransitioning:
112+
time.sleep(1)
137113

138-
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
139-
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
114+
current_level_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentLevel)
115+
asserts.assert_true(current_level_dut is not NullValue, "CurrentLevel is null")
140116

141-
asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")
142-
else:
143-
logging.info("Test step skipped")
117+
asserts.assert_equal(current_level_dut, 0, "CurrentLevel is not the expected value")
144118

145119

146120
if __name__ == "__main__":

src/python_testing/TC_VALCC_3_3.py

+35-62
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import chip.clusters as Clusters
3131
from chip.clusters.Types import NullValue
3232
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
3434
from mobly import asserts
3535

3636

@@ -56,96 +56,69 @@ def steps_TC_VALCC_3_3(self) -> list[TestStep]:
5656
]
5757
return steps
5858

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))
6660
async def test_TC_VALCC_3_3(self):
6761

68-
endpoint = self.user_params.get("endpoint", 1)
62+
endpoint = self.matter_test_config.endpoint
6963

7064
self.step(1)
7165
attributes = Clusters.ValveConfigurationAndControl.Attributes
7266

7367
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
7569

7670
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)
8172

8273
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
9179

9280
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)
9582

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")
10085

10186
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")
10589

106-
while current_level_dut != defaultOpenLevel:
107-
time.sleep(1)
90+
while current_level_dut != defaultOpenLevel:
91+
time.sleep(1)
10892

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")
11195

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")
11597

11698
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
125104

126105
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)
129107

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")
134110

135111
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")
139114

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)
142117

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")
145120

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")
149122

150123

151124
if __name__ == "__main__":

src/python_testing/TC_VALCC_3_4.py

+4-23
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import chip.clusters as Clusters
3030
from chip.interaction_model import InteractionModelError, Status
31-
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
31+
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_attribute, run_if_endpoint_matches
3232
from mobly import asserts
3333

3434

@@ -51,36 +51,17 @@ def steps_TC_VALCC_3_4(self) -> list[TestStep]:
5151
]
5252
return steps
5353

54-
def pics_TC_VALCC_3_4(self) -> list[str]:
55-
pics = [
56-
"VALCC.S",
57-
]
58-
return pics
59-
60-
@async_test_body
54+
@run_if_endpoint_matches(has_attribute(Clusters.ValveConfigurationAndControl.Attributes.LevelStep))
6155
async def test_TC_VALCC_3_4(self):
6256

63-
endpoint = self.user_params.get("endpoint", 1)
57+
endpoint = self.matter_test_config.endpoint
6458

6559
self.step(1)
6660
attributes = Clusters.ValveConfigurationAndControl.Attributes
6761

6862
self.step(2)
69-
attribute_list = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList)
70-
7163
self.step(3)
72-
if attributes.LevelStep.attribute_id not in attribute_list:
73-
logging.info("LevelStep not supported skipping test case")
74-
75-
# Skipping all remainig steps
76-
for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]:
77-
self.step(step.test_plan_number)
78-
logging.info("Test step skipped")
79-
80-
return
81-
82-
else:
83-
logging.info("Test step skipped")
64+
# Steps 2 and three are handled by the decorator
8465

8566
self.step(4)
8667
levelStep = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.LevelStep)

0 commit comments

Comments
 (0)