Skip to content

Commit 6cd72e8

Browse files
committed
implement TC_TCTL_2_3 in Python
1 parent fb24b90 commit 6cd72e8

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

src/python_testing/TC_TCTL_2_3.py

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
# === BEGIN CI TEST ARGUMENTS ===
18+
# test-runner-runs:
19+
# run1:
20+
# app: ${ALL_CLUSTERS_APP}
21+
# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json
22+
# script-args: >
23+
# --storage-path admin_storage.json
24+
# --commissioning-method on-network
25+
# --discriminator 1234
26+
# --passcode 20202021
27+
# --trace-to json:${TRACE_TEST_JSON}.json
28+
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
29+
# --PICS src/app/tests/suites/certification/ci-pics-values
30+
# factory-reset: true
31+
# quiet: true
32+
# === END CI TEST ARGUMENTS ===
33+
34+
import chip.clusters as Clusters
35+
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
36+
from mobly import asserts
37+
38+
39+
class TC_TCTL_2_3(MatterBaseTest):
40+
def desc_TC_TCTL_2_3(self) -> str:
41+
return "[TC-TCTL-2.3] Optional temperature level attributes with DUT as Server"
42+
43+
def pics_TC_TCTL_2_3(self):
44+
"""Return the PICS definitions associated with this test."""
45+
pics = [
46+
"TCTL.S", # Temperature Control as a Server
47+
"TCTL.S.F01", # Does a device support temperature level feature
48+
]
49+
return pics
50+
51+
def steps_TC_TCTL_2_3(self) -> list[TestStep]:
52+
steps = [
53+
TestStep(1, "Commissioning, already done", is_commissioning=True),
54+
TestStep(2, "TH reads from the DUT the SelectedTemperatureLevel attribute"),
55+
TestStep(3, "TH reads from the DUT the SupportedTemperatureLevels attribute and verifies string lengths"),
56+
]
57+
return steps
58+
59+
@async_test_body
60+
async def test_TC_TCTL_2_3(self):
61+
self.step(1)
62+
63+
# Step 2: Read SelectedTemperatureLevel attribute
64+
self.step(2)
65+
if self.check_pics("TCTL.S.A0004"): # SelectedTemperatureLevel attribute
66+
selected_temp = await self.default_controller.ReadAttribute(
67+
nodeid=self.dut_node_id,
68+
attributes=[(1, Clusters.TemperatureControl.Attributes.SelectedTemperatureLevel)]
69+
)
70+
temp_level = selected_temp[1][Clusters.TemperatureControl][Clusters.TemperatureControl.Attributes.SelectedTemperatureLevel]
71+
asserts.assert_true(0 <= temp_level <= 31,
72+
f"SelectedTemperatureLevel {temp_level} is out of range [0-31]")
73+
74+
# Step 3: Read SupportedTemperatureLevels attribute
75+
self.step(3)
76+
if self.check_pics("TCTL.S.A0004"): # SupportedTemperatureLevels attribute
77+
supported_temps = await self.default_controller.ReadAttribute(
78+
nodeid=self.dut_node_id,
79+
attributes=[(1, Clusters.TemperatureControl.Attributes.SupportedTemperatureLevels)]
80+
)
81+
82+
temp_levels = supported_temps[1][Clusters.TemperatureControl][Clusters.TemperatureControl.Attributes.SupportedTemperatureLevels]
83+
asserts.assert_true(isinstance(temp_levels, list),
84+
"SupportedTemperatureLevels should be a list")
85+
asserts.assert_true(len(temp_levels) <= 32,
86+
f"SupportedTemperatureLevels list length {len(temp_levels)} exceeds maximum of 32")
87+
88+
# Verify string lengths
89+
for level in temp_levels:
90+
asserts.assert_true(isinstance(level, str),
91+
f"Temperature level {level} is not a string")
92+
asserts.assert_true(len(level) <= 16,
93+
f"Temperature level string '{level}' exceeds maximum length of 16")
94+
95+
96+
if __name__ == "__main__":
97+
default_matter_test_main()

0 commit comments

Comments
 (0)