|
| 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 | +# --endpoint 1 |
| 28 | +# --trace-to json:${TRACE_TEST_JSON}.json |
| 29 | +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto |
| 30 | +# --PICS src/app/tests/suites/certification/ci-pics-values |
| 31 | +# factory-reset: true |
| 32 | +# quiet: true |
| 33 | +# === END CI TEST ARGUMENTS === |
| 34 | + |
| 35 | +import chip.clusters as Clusters |
| 36 | +from chip.testing.matter_testing import MatterBaseTest, TestStep, default_matter_test_main, has_feature, run_if_endpoint_matches |
| 37 | +from mobly import asserts |
| 38 | + |
| 39 | + |
| 40 | +class TC_TCTL_2_3(MatterBaseTest): |
| 41 | + def desc_TC_TCTL_2_3(self) -> str: |
| 42 | + return "[TC-TCTL-2.3] Optional temperature level attributes with DUT as Server" |
| 43 | + |
| 44 | + def pics_TC_TCTL_2_3(self): |
| 45 | + """Return the PICS definitions associated with this test.""" |
| 46 | + pics = [ |
| 47 | + "TCTL.S", # Temperature Control as a Server |
| 48 | + "TCTL.S.F01", # Does a device support temperature level feature |
| 49 | + ] |
| 50 | + return pics |
| 51 | + |
| 52 | + def steps_TC_TCTL_2_3(self) -> list[TestStep]: |
| 53 | + steps = [ |
| 54 | + TestStep(1, "Commissioning, already done", is_commissioning=True), |
| 55 | + TestStep(2, "TH reads from the DUT the SelectedTemperatureLevel attribute", |
| 56 | + "Verify that the DUT response contains the value of _SelectedTemperatureLevel_ with a range of 0 to 31"), |
| 57 | + TestStep(3, "TH reads from the DUT the SupportedTemperatureLevels attribute and verifies string lengths", |
| 58 | + ("Verify that the DUT response contains a _SupportedTemperatureLevels_ list\n\n" |
| 59 | + "* List length has to be equal or less than 32 \n" |
| 60 | + "* Each temperature level should be a string\n" |
| 61 | + "* Length of each temperature level string has to be equal or less than 16\n")), |
| 62 | + ] |
| 63 | + return steps |
| 64 | + |
| 65 | + @run_if_endpoint_matches(has_feature(Clusters.TemperatureControl, Clusters.TemperatureControl.Bitmaps.Feature.kTemperatureLevel)) |
| 66 | + async def test_TC_TCTL_2_3(self): |
| 67 | + self.endpoint = self.get_endpoint() |
| 68 | + cluster = Clusters.TemperatureControl |
| 69 | + attributes = cluster.Attributes |
| 70 | + self.step(1) |
| 71 | + |
| 72 | + # Step 2: Read SelectedTemperatureLevel attribute |
| 73 | + self.step(2) |
| 74 | + selected_temp = await self.read_single_attribute_check_success( |
| 75 | + cluster=cluster, |
| 76 | + attribute=attributes.SelectedTemperatureLevel |
| 77 | + ) |
| 78 | + asserts.assert_true(0 <= selected_temp <= 31, |
| 79 | + f"SelectedTemperatureLevel {selected_temp} is out of range [0-31]") |
| 80 | + |
| 81 | + # Step 3: Read SupportedTemperatureLevels attribute |
| 82 | + self.step(3) |
| 83 | + supported_temps = await self.read_single_attribute_check_success( |
| 84 | + cluster=cluster, |
| 85 | + attribute=attributes.SupportedTemperatureLevels |
| 86 | + ) |
| 87 | + asserts.assert_true(isinstance(supported_temps, list), |
| 88 | + "SupportedTemperatureLevels should be a list") |
| 89 | + asserts.assert_true(len(supported_temps) <= 32, |
| 90 | + f"SupportedTemperatureLevels list length {len(supported_temps)} exceeds maximum of 32") |
| 91 | + |
| 92 | + # Verify string lengths |
| 93 | + for level in supported_temps: |
| 94 | + asserts.assert_true(isinstance(level, str), |
| 95 | + f"Temperature level {level} is not a string") |
| 96 | + asserts.assert_true(len(level) <= 16, |
| 97 | + f"Temperature level string '{level}' exceeds maximum length of 16") |
| 98 | + |
| 99 | + |
| 100 | +if __name__ == "__main__": |
| 101 | + default_matter_test_main() |
0 commit comments