Skip to content

Commit 76939b0

Browse files
committed
Change name of decorator
1 parent 7d9a332 commit 76939b0

8 files changed

+51
-50
lines changed

src/python_testing/TC_CCTRL_2_1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717

1818
import chip.clusters as Clusters
19-
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_cluster, per_endpoint_test
19+
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, has_cluster, run_for_each_matching_endpoint
2020
from mobly import asserts
2121

2222

@@ -27,7 +27,7 @@ def steps_TC_CCTRL_2_1(self) -> list[TestStep]:
2727
TestStep(2, "Validate SupportedDeviceCategories is set accordingly based on MCORE.FS")]
2828
return steps
2929

30-
@per_endpoint_test(has_cluster(Clusters.CommissionerControl))
30+
@run_for_each_matching_endpoint(has_cluster(Clusters.CommissionerControl))
3131
async def test_TC_CCTRL_2_1(self):
3232
self.step(1)
3333
is_fabric_sync_pics_enabled = self.check_pics("MCORE.FS")

src/python_testing/TC_CCTRL_2_2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from chip import ChipDeviceCtrl
3636
from chip.interaction_model import InteractionModelError, Status
3737
from matter_testing_support import (MatterBaseTest, TestStep, async_test_body, default_matter_test_main, has_cluster,
38-
per_endpoint_test)
38+
run_for_each_matching_endpoint)
3939
from mobly import asserts
4040

4141

@@ -112,7 +112,7 @@ def steps_TC_CCTRL_2_2(self) -> list[TestStep]:
112112

113113
return steps
114114

115-
@per_endpoint_test(has_cluster(Clusters.CommissionerControl))
115+
@run_for_each_matching_endpoint(has_cluster(Clusters.CommissionerControl))
116116
async def test_TC_CCTRL_2_2(self):
117117
self.is_ci = self.check_pics('PICS_SDK_CI_ONLY')
118118

src/python_testing/TC_CC_2_2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import chip.clusters as Clusters
3434
from chip.clusters import ClusterObjects as ClusterObjects
3535
from matter_testing_support import (ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, default_matter_test_main,
36-
has_cluster, per_endpoint_test)
36+
has_cluster, run_for_each_matching_endpoint)
3737
from mobly import asserts
3838
from test_plan_support import commission_if_required, if_feature_supported, read_attribute, verify_success
3939

@@ -107,7 +107,7 @@ def entry_count_verification() -> str:
107107
"The third entry in _reportedRemainingTimeValuesList_ is equal to 0")
108108
]
109109

110-
@per_endpoint_test(has_cluster(Clusters.ColorControl))
110+
@run_for_each_matching_endpoint(has_cluster(Clusters.ColorControl))
111111
async def test_TC_CC_2_2(self):
112112
gather_time = 20
113113

src/python_testing/TC_LVL_2_3.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import chip.clusters as Clusters
3434
import test_plan_support
3535
from matter_testing_support import (ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, default_matter_test_main,
36-
has_cluster, per_endpoint_test)
36+
has_cluster, run_for_each_matching_endpoint)
3737
from mobly import asserts
3838

3939

@@ -81,7 +81,7 @@ def steps_TC_LVL_2_3(self) -> list[TestStep]:
8181
"The third entry in reportedRemainingTimeValuesList is equal to 0")
8282
]
8383

84-
@per_endpoint_test(has_cluster(Clusters.LevelControl))
84+
@run_for_each_matching_endpoint(has_cluster(Clusters.LevelControl))
8585
async def test_TC_LVL_2_3(self):
8686
# Commissioning - already done
8787
self.step(1)

src/python_testing/TC_SWTCH.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from chip.clusters.Attribute import EventReadResult
4040
from chip.tlv import uint
4141
from matter_testing_support import (ClusterAttributeChangeAccumulator, EventChangeCallback, MatterBaseTest, TestStep,
42-
await_sequence_of_reports, default_matter_test_main, has_feature, per_endpoint_test)
42+
await_sequence_of_reports, default_matter_test_main, has_feature, run_for_each_matching_endpoint)
4343
from mobly import asserts
4444

4545
logger = logging.getLogger(__name__)
@@ -260,7 +260,7 @@ def steps_TC_SWTCH_2_2(self):
260260
TestStep(10, "TH reads the CurrentPosition attribute from the DUT", "Verify that the value is 0"),
261261
]
262262

263-
@per_endpoint_test(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kLatchingSwitch))
263+
@run_for_each_matching_endpoint(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kLatchingSwitch))
264264
async def test_TC_SWTCH_2_2(self):
265265
post_prompt_settle_delay_seconds = 10.0
266266

@@ -346,7 +346,7 @@ def steps_TC_SWTCH_2_3(self):
346346
TestStep(9, "TH reads the CurrentPosition attribute from the DUT", "Verify that the value is 0"),
347347
]
348348

349-
@per_endpoint_test(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kMomentarySwitch))
349+
@run_for_each_matching_endpoint(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kMomentarySwitch))
350350
async def test_TC_SWTCH_2_3(self):
351351
# Commissioning - already done
352352
self.step(1)
@@ -425,7 +425,7 @@ def steps_TC_SWTCH_2_4(self):
425425
""")
426426
]
427427

428-
@per_endpoint_test(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kMomentarySwitch))
428+
@run_for_each_matching_endpoint(has_feature(Clusters.Switch, Clusters.Switch.Bitmaps.Feature.kMomentarySwitch))
429429
async def test_TC_SWTCH_2_4(self):
430430
switch_pressed_position = self._default_pressed_position
431431
post_prompt_settle_delay_seconds = 10.0
@@ -598,7 +598,7 @@ def should_run_SWTCH_2_5(wildcard, endpoint):
598598
asf = has_feature(Clusters.Switch, 0x20)
599599
return msm(wildcard, endpoint) and not asf(wildcard, endpoint)
600600

601-
@per_endpoint_test(should_run_SWTCH_2_5)
601+
@run_for_each_matching_endpoint(should_run_SWTCH_2_5)
602602
async def test_TC_SWTCH_2_5(self):
603603
# Commissioning - already done
604604
self.step(1)
@@ -773,7 +773,7 @@ def should_run_SWTCH_2_6(wildcard, endpoint):
773773
asf = has_feature(Clusters.Switch, 0x20)
774774
return msm(wildcard, endpoint) and asf(wildcard, endpoint)
775775

776-
@per_endpoint_test(should_run_SWTCH_2_6)
776+
@run_for_each_matching_endpoint(should_run_SWTCH_2_6)
777777
async def test_TC_SWTCH_2_6(self):
778778
# Commissioning - already done
779779
self.step(1)

src/python_testing/TC_TIMESYNC_2_1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import chip.clusters as Clusters
3434
from chip.clusters.Types import NullValue
35-
from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster, per_endpoint_test,
35+
from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster, run_for_each_matching_endpoint,
3636
utc_time_in_matter_epoch)
3737
from mobly import asserts
3838

@@ -42,7 +42,7 @@ async def read_ts_attribute_expect_success(self, attribute):
4242
cluster = Clusters.Objects.TimeSynchronization
4343
return await self.read_single_attribute_check_success(endpoint=None, cluster=cluster, attribute=attribute)
4444

45-
@per_endpoint_test(has_cluster(Clusters.TimeSynchronization) and has_attribute(Clusters.TimeSynchronization.Attributes.TimeSource))
45+
@run_for_each_matching_endpoint(has_cluster(Clusters.TimeSynchronization) and has_attribute(Clusters.TimeSynchronization.Attributes.TimeSource))
4646
async def test_TC_TIMESYNC_2_1(self):
4747
attributes = Clusters.TimeSynchronization.Attributes
4848
features = await self.read_ts_attribute_expect_success(attribute=attributes.FeatureMap)

src/python_testing/matter_testing_support.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -1745,15 +1745,15 @@ def async_runner(self: MatterBaseTest, *args, **kwargs):
17451745
return async_runner
17461746

17471747

1748-
def per_node_test(body):
1748+
def run_once_for_node(body):
17491749
""" Decorator to be used for PICS-free tests that apply to the entire node.
17501750
17511751
Use this decorator when your script needs to be run once to validate the whole node.
17521752
To use this decorator, the test must NOT have an associated pics_ method.
17531753
"""
17541754

17551755
def whole_node_runner(self: MatterBaseTest, *args, **kwargs):
1756-
asserts.assert_false(self.get_test_pics(self.current_test_info.name), "pics_ method supplied for per_node_test.")
1756+
asserts.assert_false(self.get_test_pics(self.current_test_info.name), "pics_ method supplied for run_once_for_node.")
17571757
return _async_runner(body, self, *args, **kwargs)
17581758

17591759
return whole_node_runner
@@ -1770,9 +1770,9 @@ def _has_cluster(wildcard, endpoint, cluster: ClusterObjects.Cluster) -> bool:
17701770

17711771

17721772
def has_cluster(cluster: ClusterObjects.ClusterObjectDescriptor) -> EndpointCheckFunction:
1773-
""" EndpointCheckFunction that can be passed as a parameter to the per_endpoint_test decorator.
1773+
""" EndpointCheckFunction that can be passed as a parameter to the run_for_each_matching_endpoint decorator.
17741774
1775-
Use this function with the per_endpoint_test decorator to run this test on all endpoints with
1775+
Use this function with the run_for_each_matching_endpoint decorator to run this test on all endpoints with
17761776
the specified cluster. For example, given a device with the following conformance
17771777
17781778
EP0: cluster A, B, C
@@ -1781,7 +1781,7 @@ def has_cluster(cluster: ClusterObjects.ClusterObjectDescriptor) -> EndpointChec
17811781
EP3, cluster E
17821782
17831783
And the following test specification:
1784-
@per_endpoint_test(has_cluster(Clusters.D))
1784+
@run_for_each_matching_endpoint(has_cluster(Clusters.D))
17851785
test_mytest(self):
17861786
...
17871787
@@ -1803,9 +1803,9 @@ def _has_attribute(wildcard, endpoint, attribute: ClusterObjects.ClusterAttribut
18031803

18041804

18051805
def has_attribute(attribute: ClusterObjects.ClusterAttributeDescriptor) -> EndpointCheckFunction:
1806-
""" EndpointCheckFunction that can be passed as a parameter to the per_endpoint_test decorator.
1806+
""" EndpointCheckFunction that can be passed as a parameter to the run_for_each_matching_endpoint decorator.
18071807
1808-
Use this function with the per_endpoint_test decorator to run this test on all endpoints with
1808+
Use this function with the run_for_each_matching_endpoint decorator to run this test on all endpoints with
18091809
the specified attribute. For example, given a device with the following conformance
18101810
18111811
EP0: cluster A, B, C
@@ -1814,7 +1814,7 @@ def has_attribute(attribute: ClusterObjects.ClusterAttributeDescriptor) -> Endpo
18141814
EP3, cluster D without attribute d
18151815
18161816
And the following test specification:
1817-
@per_endpoint_test(has_attribute(Clusters.D.Attributes.d))
1817+
@run_for_each_matching_endpoint(has_attribute(Clusters.D.Attributes.d))
18181818
test_mytest(self):
18191819
...
18201820
@@ -1835,9 +1835,9 @@ def _has_feature(wildcard, endpoint, cluster: ClusterObjects.ClusterObjectDescri
18351835

18361836

18371837
def has_feature(cluster: ClusterObjects.ClusterObjectDescriptor, feature: IntFlag) -> EndpointCheckFunction:
1838-
""" EndpointCheckFunction that can be passed as a parameter to the per_endpoint_test decorator.
1838+
""" EndpointCheckFunction that can be passed as a parameter to the run_for_each_matching_endpoint decorator.
18391839
1840-
Use this function with the per_endpoint_test decorator to run this test on all endpoints with
1840+
Use this function with the run_for_each_matching_endpoint decorator to run this test on all endpoints with
18411841
the specified feature. For example, given a device with the following conformance
18421842
18431843
EP0: cluster A, B, C
@@ -1846,7 +1846,7 @@ def has_feature(cluster: ClusterObjects.ClusterObjectDescriptor, feature: IntFla
18461846
EP3, cluster D without feature F0
18471847
18481848
And the following test specification:
1849-
@per_endpoint_test(has_feature(Clusters.D.Bitmaps.Feature.F0))
1849+
@run_for_each_matching_endpoint(has_feature(Clusters.D.Bitmaps.Feature.F0))
18501850
test_mytest(self):
18511851
...
18521852
@@ -1859,15 +1859,15 @@ def has_feature(cluster: ClusterObjects.ClusterObjectDescriptor, feature: IntFla
18591859

18601860

18611861
async def get_accepted_endpoints_for_test(self: MatterBaseTest, accept_function: EndpointCheckFunction) -> list[uint]:
1862-
""" Helper function for the per_endpoint_test decorator.
1862+
""" Helper function for the run_for_each_matching_endpoint decorator.
18631863
18641864
Returns a list of endpoints on which the test should be run given the accept_function for the test.
18651865
"""
18661866
wildcard = await self.default_controller.Read(self.dut_node_id, [()])
18671867
return [e for e in wildcard.attributes.keys() if accept_function(wildcard, e)]
18681868

18691869

1870-
def per_endpoint_test(accept_function: EndpointCheckFunction):
1870+
def run_for_each_matching_endpoint(accept_function: EndpointCheckFunction):
18711871
""" Test decorator for a test that needs to be run once per endpoint that meets the accept_function criteria.
18721872
18731873
Place this decorator above the test_ method to have the test framework run this test once per endpoint.
@@ -1882,7 +1882,7 @@ def per_endpoint_test(accept_function: EndpointCheckFunction):
18821882
EP3, cluster E
18831883
18841884
And the following test specification:
1885-
@per_endpoint_test(has_cluster(Clusters.D))
1885+
@run_for_each_matching_endpoint(has_cluster(Clusters.D))
18861886
test_mytest(self):
18871887
...
18881888
@@ -1898,9 +1898,10 @@ def per_endpoint_test(accept_function: EndpointCheckFunction):
18981898
Tests that use this decorator cannot use a pics_ method for test selection and should not reference any
18991899
PICS values internally.
19001900
"""
1901-
def per_endpoint_test_internal(body):
1901+
def run_for_each_matching_endpoint_internal(body):
19021902
def per_endpoint_runner(self: MatterBaseTest, *args, **kwargs):
1903-
asserts.assert_false(self.get_test_pics(self.current_test_info.name), "pics_ method supplied for per_endpoint_test.")
1903+
asserts.assert_false(self.get_test_pics(self.current_test_info.name),
1904+
"pics_ method supplied for run_for_each_matching_endpoint.")
19041905
runner_with_timeout = asyncio.wait_for(get_accepted_endpoints_for_test(self, accept_function), timeout=30)
19051906
endpoints = asyncio.run(runner_with_timeout)
19061907
if not endpoints:
@@ -1927,7 +1928,7 @@ def per_endpoint_runner(self: MatterBaseTest, *args, **kwargs):
19271928
self.runner_hook.test_stop(exception=None, duration=test_duration)
19281929
self.matter_test_config.endpoint = original_ep
19291930
return per_endpoint_runner
1930-
return per_endpoint_test_internal
1931+
return run_for_each_matching_endpoint_internal
19311932

19321933

19331934
class CommissionDeviceTest(MatterBaseTest):

src/python_testing/test_testing/TestDecorators.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
try:
3535
from matter_testing_support import (MatterBaseTest, async_test_body, get_accepted_endpoints_for_test, has_attribute,
36-
has_cluster, has_feature, per_endpoint_test, per_node_test)
36+
has_cluster, has_feature, run_for_each_matching_endpoint, run_once_for_node)
3737
except ImportError:
3838
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
3939
from matter_testing_support import (MatterBaseTest, async_test_body, get_accepted_endpoints_for_test, has_attribute,
40-
has_cluster, has_feature, per_endpoint_test, per_node_test)
40+
has_cluster, has_feature, run_for_each_matching_endpoint, run_once_for_node)
4141

4242
from typing import Optional
4343

@@ -154,7 +154,7 @@ async def test_endpoints(self):
154154
asserts.assert_equal(endpoints, [], msg)
155155

156156
# This test should cause an assertion because it has pics_ method
157-
@per_node_test
157+
@run_once_for_node
158158
async def test_whole_node_with_pics(self):
159159
pass
160160

@@ -164,7 +164,7 @@ def pics_whole_node_with_pics(self):
164164
return ['EXAMPLE.S']
165165

166166
# This test should cause an assertion because it has a pics_ method
167-
@per_endpoint_test(has_cluster(Clusters.OnOff))
167+
@run_for_each_matching_endpoint(has_cluster(Clusters.OnOff))
168168
async def test_per_endpoint_with_pics(self):
169169
pass
170170

@@ -174,66 +174,66 @@ def pics_per_endpoint_with_pics(self):
174174
return ['EXAMPLE.S']
175175

176176
# This test should be run once
177-
@per_node_test
177+
@run_once_for_node
178178
async def test_whole_node_ok(self):
179179
pass
180180

181181
# This test should be run once per endpoint
182-
@per_endpoint_test(has_cluster(Clusters.OnOff))
182+
@run_for_each_matching_endpoint(has_cluster(Clusters.OnOff))
183183
async def test_endpoint_cluster_yes(self):
184184
pass
185185

186186
# This test should be skipped since this cluster isn't on any endpoint
187-
@per_endpoint_test(has_cluster(Clusters.TimeSynchronization))
187+
@run_for_each_matching_endpoint(has_cluster(Clusters.TimeSynchronization))
188188
async def test_endpoint_cluster_no(self):
189189
pass
190190

191191
# This test should be run once per endpoint
192-
@per_endpoint_test(has_attribute(Clusters.OnOff.Attributes.OnOff))
192+
@run_for_each_matching_endpoint(has_attribute(Clusters.OnOff.Attributes.OnOff))
193193
async def test_endpoint_attribute_yes(self):
194194
pass
195195

196196
# This test should be skipped since this attribute isn't on the supported cluster
197-
@per_endpoint_test(has_attribute(Clusters.OnOff.Attributes.OffWaitTime))
197+
@run_for_each_matching_endpoint(has_attribute(Clusters.OnOff.Attributes.OffWaitTime))
198198
async def test_endpoint_attribute_supported_cluster_no(self):
199199
pass
200200

201201
# This test should be skipped since this attribute is part of an unsupported cluster
202-
@per_endpoint_test(has_attribute(Clusters.TimeSynchronization.Attributes.Granularity))
202+
@run_for_each_matching_endpoint(has_attribute(Clusters.TimeSynchronization.Attributes.Granularity))
203203
async def test_endpoint_attribute_unsupported_cluster_no(self):
204204
pass
205205

206206
# This test should be run once per endpoint
207-
@per_endpoint_test(has_feature(Clusters.OnOff, Clusters.OnOff.Bitmaps.Feature.kLighting))
207+
@run_for_each_matching_endpoint(has_feature(Clusters.OnOff, Clusters.OnOff.Bitmaps.Feature.kLighting))
208208
async def test_endpoint_feature_yes(self):
209209
pass
210210

211211
# This test should be skipped since this attribute is part of an unsupported cluster
212-
@per_endpoint_test(has_feature(Clusters.TimeSynchronization, Clusters.TimeSynchronization.Bitmaps.Feature.kNTPClient))
212+
@run_for_each_matching_endpoint(has_feature(Clusters.TimeSynchronization, Clusters.TimeSynchronization.Bitmaps.Feature.kNTPClient))
213213
async def test_endpoint_feature_unsupported_cluster_no(self):
214214
pass
215215

216216
# This test should be run since both are present
217-
@per_endpoint_test(has_attribute(Clusters.OnOff.Attributes.OnOff) and has_cluster(Clusters.OnOff))
217+
@run_for_each_matching_endpoint(has_attribute(Clusters.OnOff.Attributes.OnOff) and has_cluster(Clusters.OnOff))
218218
async def test_endpoint_boolean_yes(self):
219219
pass
220220

221221
# This test should be skipped since we have an OnOff cluster, but no Time sync
222-
@per_endpoint_test(has_cluster(Clusters.OnOff) and has_cluster(Clusters.TimeSynchronization))
222+
@run_for_each_matching_endpoint(has_cluster(Clusters.OnOff) and has_cluster(Clusters.TimeSynchronization))
223223
async def test_endpoint_boolean_no(self):
224224
pass
225225

226-
@per_endpoint_test(has_cluster(Clusters.OnOff))
226+
@run_for_each_matching_endpoint(has_cluster(Clusters.OnOff))
227227
async def test_fail_on_ep0(self):
228228
if self.matter_test_config.endpoint == 0:
229229
asserts.fail("Expected failure")
230230

231-
@per_endpoint_test(has_cluster(Clusters.OnOff))
231+
@run_for_each_matching_endpoint(has_cluster(Clusters.OnOff))
232232
async def test_fail_on_ep1(self):
233233
if self.matter_test_config.endpoint == 1:
234234
asserts.fail("Expected failure")
235235

236-
@per_node_test
236+
@run_once_for_node
237237
async def test_fail_on_whole_node(self):
238238
asserts.fail("Expected failure")
239239

0 commit comments

Comments
 (0)