From 46c6878b04710205a49b3b0433e1878192d79a37 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 07:00:45 -0600 Subject: [PATCH 1/8] Implement TC_LWM_1_2 with Python --- src/python_testing/TC_LWM_1_2.py | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/python_testing/TC_LWM_1_2.py diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py new file mode 100644 index 00000000000000..59d39415af09b4 --- /dev/null +++ b/src/python_testing/TC_LWM_1_2.py @@ -0,0 +1,110 @@ +# +# Copyright (c) 2025 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# FIXME: https://github.com/project-chip/connectedhomeip/issues/36885 +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: +# run1: +# app: ${CHIP_MICROWAVE_OVEN_APP} +# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# script-args: > +# --storage-path admin_storage.json +# --commissioning-method on-network +# --discriminator 1234 +# --passcode 20202021 +# --PICS src/app/tests/suites/certification/ci-pics-values +# --endpoint 1 +# --trace-to json:${TRACE_TEST_JSON}.json +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# factory-reset: true +# quiet: true +# === END CI TEST ARGUMENTS === + + +import chip.clusters as Clusters +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from modebase_cluster_check import ModeBaseClusterChecks + +CLUSTER = Clusters.RefrigeratorAndTemperatureControlledCabinetMode + + +class TC_LWM_1_2(MatterBaseTest, ModeBaseClusterChecks): + + def __init__(self, *args): + MatterBaseTest.__init__(self, *args) + ModeBaseClusterChecks.__init__(self, + modebase_derived_cluster=CLUSTER) + + def desc_TC_LWM_1_2(self) -> str: + return "[TC-LWM-1.2] Cluster attributes with DUT as Server" + + def steps_TC_LWM_1_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH reads from the DUT the SupportedModes attribute."), + TestStep(3, "TH reads from the DUT the CurrentMode attribute."), + TestStep(4, "TH reads from the DUT the OnMode attribute."), + TestStep(5, "TH reads from the DUT the StartUpMode attribute.") + ] + return steps + + def pics_TC_LWM_1_2(self) -> list[str]: + pics = [ + "LWM.S" + ] + return pics + + @async_test_body + async def test_TC_LWM_1_2(self): + + # Setup common mode check + endpoint = self.get_endpoint(default=1) + + self.step(1) + + self.step(2) + # Verify common checks for Mode Base as described in the TC-LWM-1.2 + supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) + # According to the spec, there should be at least one RapidCool or RapidFreeze tag in + # the ones supported. + additional_tags = [CLUSTER.Enums.ModeTag.kRapidCool, + CLUSTER.Enums.ModeTag.kRapidFreeze] + self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) + + self.step(3) + # Verify that the CurrentMode attribute has a valid value. + mode = self.cluster.Attributes.CurrentMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) + + self.step(4) + # Verify that the OnMode attribute has a valid value or null. + mode = self.cluster.Attributes.OnMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, + supported_modes=supported_modes, is_nullable=True) + + self.step(5) + # Verify that the StartUpMode has a valid value or null + mode = self.cluster.Attributes.StartUpMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, + supported_modes=supported_modes, is_nullable=True) + + +if __name__ == "__main__": + default_matter_test_main() From 0924a450028afc2c089d1cfe670e8553f9f1a74d Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 18:52:18 -0600 Subject: [PATCH 2/8] Implemented functionality to validate LWM in tests --- src/python_testing/TC_LWM_1_2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index 59d39415af09b4..2014e5b22c00fa 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -42,7 +42,7 @@ from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from modebase_cluster_check import ModeBaseClusterChecks -CLUSTER = Clusters.RefrigeratorAndTemperatureControlledCabinetMode +CLUSTER = Clusters.LaundryWasherMode class TC_LWM_1_2(MatterBaseTest, ModeBaseClusterChecks): @@ -82,16 +82,16 @@ async def test_TC_LWM_1_2(self): self.step(2) # Verify common checks for Mode Base as described in the TC-LWM-1.2 supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) - # According to the spec, there should be at least one RapidCool or RapidFreeze tag in + # According to the spec, there should be at least one Normal, Delicate, or Heavy tag in # the ones supported. - additional_tags = [CLUSTER.Enums.ModeTag.kRapidCool, - CLUSTER.Enums.ModeTag.kRapidFreeze] + additional_tags = [CLUSTER.Enums.ModeTag.kNormal, + CLUSTER.Enums.ModeTag.kDelicate] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) self.step(3) # Verify that the CurrentMode attribute has a valid value. mode = self.cluster.Attributes.CurrentMode - await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) + resp = await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) self.step(4) # Verify that the OnMode attribute has a valid value or null. From 613580efeedea8468a2aaa445f197ac7d0d48eeb Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 19:26:08 -0600 Subject: [PATCH 3/8] Update functionality to validate LWM in tests --- src/python_testing/TC_LWM_1_2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index 2014e5b22c00fa..9beb8362a497c5 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -82,8 +82,9 @@ async def test_TC_LWM_1_2(self): self.step(2) # Verify common checks for Mode Base as described in the TC-LWM-1.2 supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) - # According to the spec, there should be at least one Normal, Delicate, or Heavy tag in - # the ones supported. + # According to the spec, there should be at least one like + # Normal, Delicate, Heavy, or Whites + # tag in the ones supported. additional_tags = [CLUSTER.Enums.ModeTag.kNormal, CLUSTER.Enums.ModeTag.kDelicate] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) From b9616fd38a793cf97b918746512a15135789880b Mon Sep 17 00:00:00 2001 From: juandediosg Date: Tue, 18 Feb 2025 17:10:37 -0600 Subject: [PATCH 4/8] Fixed: Updated CI Test arguments --- src/python_testing/TC_LWM_1_2.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index 9beb8362a497c5..e8df9dedcaa902 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -15,21 +15,19 @@ # limitations under the License. # -# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments -# for details about the block below. -# -# FIXME: https://github.com/project-chip/connectedhomeip/issues/36885 # === BEGIN CI TEST ARGUMENTS === # test-runner-runs: # run1: -# app: ${CHIP_MICROWAVE_OVEN_APP} -# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# app: ${ALL_CLUSTERS_APP} +# app-args: > +# --discriminator 1234 +# --KVS kvs1 +# --trace-to json:${TRACE_APP}.json # script-args: > # --storage-path admin_storage.json # --commissioning-method on-network # --discriminator 1234 # --passcode 20202021 -# --PICS src/app/tests/suites/certification/ci-pics-values # --endpoint 1 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto From f3d39483973e49d073e458c095727112e0650c7a Mon Sep 17 00:00:00 2001 From: juandediosg Date: Wed, 19 Feb 2025 13:45:52 -0600 Subject: [PATCH 5/8] Fixed: Lint Code Base --- src/python_testing/TC_LWM_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index e8df9dedcaa902..9009dadfae2c94 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -90,7 +90,7 @@ async def test_TC_LWM_1_2(self): self.step(3) # Verify that the CurrentMode attribute has a valid value. mode = self.cluster.Attributes.CurrentMode - resp = await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) + await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) self.step(4) # Verify that the OnMode attribute has a valid value or null. From 8ae703773f7704327191d28b8c013b91b3b05767 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Wed, 19 Feb 2025 19:25:43 -0600 Subject: [PATCH 6/8] Updated: Removed validations for disallowed attributes (OnMode and StartupMode) based on specs from Test Plan. --- src/python_testing/TC_LWM_1_2.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index 9009dadfae2c94..4c0dcf78159655 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -57,9 +57,7 @@ def steps_TC_LWM_1_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the SupportedModes attribute."), - TestStep(3, "TH reads from the DUT the CurrentMode attribute."), - TestStep(4, "TH reads from the DUT the OnMode attribute."), - TestStep(5, "TH reads from the DUT the StartUpMode attribute.") + TestStep(3, "TH reads from the DUT the CurrentMode attribute.") ] return steps @@ -92,18 +90,6 @@ async def test_TC_LWM_1_2(self): mode = self.cluster.Attributes.CurrentMode await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) - self.step(4) - # Verify that the OnMode attribute has a valid value or null. - mode = self.cluster.Attributes.OnMode - await self.read_and_check_mode(endpoint=endpoint, mode=mode, - supported_modes=supported_modes, is_nullable=True) - - self.step(5) - # Verify that the StartUpMode has a valid value or null - mode = self.cluster.Attributes.StartUpMode - await self.read_and_check_mode(endpoint=endpoint, mode=mode, - supported_modes=supported_modes, is_nullable=True) - if __name__ == "__main__": default_matter_test_main() From f5e814320f6faa9e01c80c1244f03029b9cd50fc Mon Sep 17 00:00:00 2001 From: juandediosg Date: Thu, 20 Feb 2025 15:52:08 -0600 Subject: [PATCH 7/8] Fixed: Renamed CLUSTER to cluster_lwm_mode for clarity, keeping it outside the class. --- src/python_testing/TC_LWM_1_2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index 4c0dcf78159655..c39a9f5e029541 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -40,7 +40,7 @@ from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from modebase_cluster_check import ModeBaseClusterChecks -CLUSTER = Clusters.LaundryWasherMode +cluster_lwm_mode = Clusters.LaundryWasherMode class TC_LWM_1_2(MatterBaseTest, ModeBaseClusterChecks): @@ -48,7 +48,7 @@ class TC_LWM_1_2(MatterBaseTest, ModeBaseClusterChecks): def __init__(self, *args): MatterBaseTest.__init__(self, *args) ModeBaseClusterChecks.__init__(self, - modebase_derived_cluster=CLUSTER) + modebase_derived_cluster=cluster_lwm_mode) def desc_TC_LWM_1_2(self) -> str: return "[TC-LWM-1.2] Cluster attributes with DUT as Server" @@ -81,13 +81,13 @@ async def test_TC_LWM_1_2(self): # According to the spec, there should be at least one like # Normal, Delicate, Heavy, or Whites # tag in the ones supported. - additional_tags = [CLUSTER.Enums.ModeTag.kNormal, - CLUSTER.Enums.ModeTag.kDelicate] + additional_tags = [cluster_lwm_mode.Enums.ModeTag.kNormal, + cluster_lwm_mode.Enums.ModeTag.kDelicate] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) self.step(3) # Verify that the CurrentMode attribute has a valid value. - mode = self.cluster.Attributes.CurrentMode + mode = cluster_lwm_mode.Attributes.CurrentMode await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) From 2d63372e43a2fc63bb45052f307be64bc045cd56 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Thu, 20 Feb 2025 18:28:07 -0600 Subject: [PATCH 8/8] Fixed: Verification CurrentMode. --- src/python_testing/TC_LWM_1_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_LWM_1_2.py b/src/python_testing/TC_LWM_1_2.py index c39a9f5e029541..5577a03676c5cf 100644 --- a/src/python_testing/TC_LWM_1_2.py +++ b/src/python_testing/TC_LWM_1_2.py @@ -87,7 +87,7 @@ async def test_TC_LWM_1_2(self): self.step(3) # Verify that the CurrentMode attribute has a valid value. - mode = cluster_lwm_mode.Attributes.CurrentMode + mode = self.cluster.Attributes.CurrentMode await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes)