|
| 1 | +# |
| 2 | +# Copyright (c) 2025 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 | +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments |
| 19 | +# for details about the block below. |
| 20 | +# |
| 21 | +# FIXME: https://github.com/project-chip/connectedhomeip/issues/36885 |
| 22 | +# === BEGIN CI TEST ARGUMENTS === |
| 23 | +# test-runner-runs: |
| 24 | +# run1: |
| 25 | +# app: ${CHIP_MICROWAVE_OVEN_APP} |
| 26 | +# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json |
| 27 | +# script-args: > |
| 28 | +# --storage-path admin_storage.json |
| 29 | +# --commissioning-method on-network |
| 30 | +# --discriminator 1234 |
| 31 | +# --passcode 20202021 |
| 32 | +# --PICS src/app/tests/suites/certification/ci-pics-values |
| 33 | +# --endpoint 1 |
| 34 | +# --trace-to json:${TRACE_TEST_JSON}.json |
| 35 | +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto |
| 36 | +# factory-reset: true |
| 37 | +# quiet: true |
| 38 | +# === END CI TEST ARGUMENTS === |
| 39 | + |
| 40 | + |
| 41 | +import chip.clusters as Clusters |
| 42 | +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main |
| 43 | +from modebase_cluster_check import ModeBaseClusterChecks |
| 44 | + |
| 45 | +CLUSTER = Clusters.RefrigeratorAndTemperatureControlledCabinetMode |
| 46 | + |
| 47 | + |
| 48 | +class TC_DEMM_1_2(MatterBaseTest, ModeBaseClusterChecks): |
| 49 | + |
| 50 | + def __init__(self, *args): |
| 51 | + MatterBaseTest.__init__(self, *args) |
| 52 | + ModeBaseClusterChecks.__init__(self, |
| 53 | + modebase_derived_cluster=CLUSTER) |
| 54 | + |
| 55 | + def desc_TC_DEMM_1_2(self) -> str: |
| 56 | + return "[TC-DEMM-1.2] Cluster attributes with DUT as Server" |
| 57 | + |
| 58 | + def steps_TC_DEMM_1_2(self) -> list[TestStep]: |
| 59 | + steps = [ |
| 60 | + TestStep(1, "Commissioning, already done", is_commissioning=True), |
| 61 | + TestStep(2, "TH reads from the DUT the SupportedModes attribute."), |
| 62 | + TestStep(3, "TH reads from the DUT the CurrentMode attribute."), |
| 63 | + TestStep(4, "TH reads from the DUT the OnMode attribute."), |
| 64 | + TestStep(5, "TH reads from the DUT the StartUpMode attribute.") |
| 65 | + ] |
| 66 | + return steps |
| 67 | + |
| 68 | + def pics_TC_DEMM_1_2(self) -> list[str]: |
| 69 | + pics = [ |
| 70 | + "DEMM.S" |
| 71 | + ] |
| 72 | + return pics |
| 73 | + |
| 74 | + @async_test_body |
| 75 | + async def test_TC_DEMM_1_2(self): |
| 76 | + |
| 77 | + # Setup common mode check |
| 78 | + endpoint = self.get_endpoint(default=1) |
| 79 | + |
| 80 | + self.step(1) |
| 81 | + |
| 82 | + self.step(2) |
| 83 | + # Verify common checks for Mode Base as described in the TC-DEMM-1.2 |
| 84 | + supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) |
| 85 | + # According to the spec, there should be at least one RapidCool or RapidFreeze tag in |
| 86 | + # the ones supported. |
| 87 | + additional_tags = [CLUSTER.Enums.ModeTag.kRapidCool, |
| 88 | + CLUSTER.Enums.ModeTag.kRapidFreeze] |
| 89 | + self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) |
| 90 | + |
| 91 | + self.step(3) |
| 92 | + # Verify that the CurrentMode attribute has a valid value. |
| 93 | + mode = self.cluster.Attributes.CurrentMode |
| 94 | + await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) |
| 95 | + |
| 96 | + self.step(4) |
| 97 | + # Verify that the OnMode attribute has a valid value or null. |
| 98 | + mode = self.cluster.Attributes.OnMode |
| 99 | + await self.read_and_check_mode(endpoint=endpoint, mode=mode, |
| 100 | + supported_modes=supported_modes, is_nullable=True) |
| 101 | + |
| 102 | + self.step(5) |
| 103 | + # Verify that the StartUpMode has a valid value or null |
| 104 | + mode = self.cluster.Attributes.StartUpMode |
| 105 | + await self.read_and_check_mode(endpoint=endpoint, mode=mode, |
| 106 | + supported_modes=supported_modes, is_nullable=True) |
| 107 | + |
| 108 | + |
| 109 | +if __name__ == "__main__": |
| 110 | + default_matter_test_main() |
0 commit comments