Skip to content

Commit a870594

Browse files
committed
Python test script for Power Topology
1 parent 87b0b43 commit a870594

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

src/python_testing/TC_PWRTL_2_1.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import logging
19+
20+
import chip.clusters as Clusters
21+
from chip.clusters.Types import NullValue
22+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
23+
from mobly import asserts
24+
25+
class TC_PWRTL_2_1(MatterBaseTest):
26+
27+
def pics_TC_PWRTL_2_1(self) -> list[str]:
28+
return ["PWRTL.S"]
29+
30+
@async_test_body
31+
async def test_TC_PWRTL_2_1(self):
32+
33+
attributes = Clusters.PowerTopology.Attributes
34+
35+
endpoint = self.user_params.get("endpoint", 1)
36+
37+
self.print_step(1, "Commissioning, already done")
38+
39+
if not self.check_pics("PWRTL.S.A0000"):
40+
logging.info("Test skipped because PICS PWRTL.S.A0000 is not set")
41+
return
42+
43+
self.print_step(2, "Read AvailableAttributes attribute")
44+
available_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.AvailableEndpoints)
45+
46+
if available_endpoints == NullValue:
47+
logging.info("AvailableEndpoints is null")
48+
else:
49+
logging.info("AvailableEndpoints: %s" % (available_endpoints))
50+
51+
asserts.assert_less_equal(len(available_endpoints), 21,
52+
"AvailableEndpoints length %d must be less than 21!" % len(available_endpoints))
53+
54+
if not self.check_pics("PWRTL.S.A0001"):
55+
logging.info("Test skipped because PICS PWRTL.S.A0001 is not set")
56+
return
57+
58+
self.print_step(3, "Read ActiveEndpoints attribute")
59+
active_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.ActiveEndpoints)
60+
logging.info("ActiveEndpoints: %s" % (active_endpoints))
61+
62+
if available_endpoints == NullValue:
63+
asserts.assert_true(active_endpoints == NullValue, "ActiveEndpoints should be null when AvailableEndpoints is null: %s" % active_endpoints)
64+
65+
66+
67+
if __name__ == "__main__":
68+
default_matter_test_main()

0 commit comments

Comments
 (0)