From a81855cd726d83c0d5534f400e3eb0980c66ef36 Mon Sep 17 00:00:00 2001 From: Rob Bultman Date: Fri, 3 May 2024 16:07:21 -0400 Subject: [PATCH] Remove and rework tests per comments. --- .../certification/Test_TC_DISHM_1_1.yaml | 22 --- src/python_testing/TC_DISHM_1_2.py | 170 +++++++++--------- 2 files changed, 90 insertions(+), 102 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_DISHM_1_1.yaml b/src/app/tests/suites/certification/Test_TC_DISHM_1_1.yaml index 64673f3899e75c..ebbe846858018c 100644 --- a/src/app/tests/suites/certification/Test_TC_DISHM_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DISHM_1_1.yaml @@ -99,28 +99,6 @@ tests: type: list excludes: [2] - - label: - "4. TH reads optional attribute (DISHM.S.F00(DEPONOFF)) in - AttributeList" - PICS: DISHM.S.F00 - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [3] - - - label: - "4. TH reads optional attribute (DISHM.S.F00(DEPONOFF)) in - AttributeList" - PICS: " !DISHM.S.F00 " - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - excludes: [3] - - label: "5. TH reads from the DUT the EventList attribute" PICS: PICS_EVENT_LIST_ENABLED command: "readAttribute" diff --git a/src/python_testing/TC_DISHM_1_2.py b/src/python_testing/TC_DISHM_1_2.py index 45243aad4e47b4..e36b216eceb305 100644 --- a/src/python_testing/TC_DISHM_1_2.py +++ b/src/python_testing/TC_DISHM_1_2.py @@ -20,15 +20,33 @@ import chip.clusters as Clusters from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts - class TC_DISHM_1_2(MatterBaseTest): async def read_mode_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.DishwasherMode return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + def desc_TC_DISHM_1_2(self) -> str: + return "[TC-DISHM-1.2] Cluster attributes with DUT as Server" + + def steps_TC_DISHM_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."), + ] + return steps + + def pics_TC_DISHM_1_2(self) -> list[str]: + pics = [ + "DISHM.S", + ] + return pics + + @async_test_body async def test_TC_DISHM_1_2(self): @@ -37,85 +55,77 @@ async def test_TC_DISHM_1_2(self): attributes = Clusters.DishwasherMode.Attributes - self.print_step(1, "Commissioning, already done") - - if self.check_pics("DISHM.S.A0000"): - self.print_step(2, "Read SupportedModes attribute") - supported_modes = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.SupportedModes) - - logging.info("SupportedModes: %s" % (supported_modes)) - - asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least two entries!") - asserts.assert_less_equal(len(supported_modes), 255, "SupportedModes must have at most 255 entries!") - - supported_modes_dut = [] - for m in supported_modes: - if m.mode in supported_modes_dut: - asserts.fail("SupportedModes must have unique mode values!") - else: - supported_modes_dut.append(m.mode) - - labels = [] - for m in supported_modes: - if m.label in labels: - asserts.fail("SupportedModes must have unique mode label values!") - else: - labels.append(m.label) - - # common mode tags - commonTags = {0x0: 'Auto', - 0x1: 'Quick', - 0x2: 'Quiet', - 0x3: 'LowNoise', - 0x4: 'LowEnergy', - 0x5: 'Vacation', - 0x6: 'Min', - 0x7: 'Max', - 0x8: 'Night', - 0x9: 'Day'} - - # kUnknownEnumValue may not be defined - try: - modeTags = [tag.value for tag in Clusters.DishwasherMode.Enums.ModeTag - if tag is not Clusters.DishwasherMode.Enums.ModeTag.kUnknownEnumValue] - except AttributeError: - modeTags = Clusters.DishwasherMode.Enums.ModeTag - - for m in supported_modes: - for t in m.modeTags: - is_mfg = (0x8000 <= t.value and t.value <= 0xBFFF) - asserts.assert_true(t.value <= 0xFFFF, "Tag value is > 16 bits") - asserts.assert_true(t.value in commonTags.keys() or t.value in modeTags or is_mfg, - "Found a SupportedModes entry with invalid mode tag value!") - - asserts.assert_true(type(m.label) is str and len(m.label) in range(1, 65), - "TagName is not the appropriate length or type") - if t.value == Clusters.DishwasherMode.Enums.ModeTag.kNormal: - normal_present = True - asserts.assert_true(normal_present, "The Supported Modes does not have an entry of Normal(0x4000)") - - if self.check_pics("DISHM.S.A0001"): - self.print_step(3, "Read CurrentMode attribute") - current_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - - logging.info("CurrentMode: %s" % (current_mode)) - asserts.assert_true(current_mode in supported_modes_dut, "CurrentMode is not a supported mode!") - - if self.check_pics("DISHM.S.A0003"): - self.print_step(4, "Read OnMode attribute") - on_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OnMode) - - logging.info("OnMode: %s" % (on_mode)) - asserts.assert_true(on_mode in supported_modes_dut or on_mode == NullValue, "OnMode is not a supported mode!") - - if self.check_pics("DISHM.S.A0002"): - self.print_step(5, "Read StartUpMode attribute") - startup_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.StartUpMode) - - logging.info("StartUpMode: %s" % (startup_mode)) - asserts.assert_true(startup_mode in supported_modes_dut or startup_mode == - NullValue, "StartUpMode is not a supported mode!") - + self.step(1) + + self.step(2) + supported_modes = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.SupportedModes) + + logging.info("SupportedModes: %s" % (supported_modes)) + + # Check the number of modes in SupportedModes. + asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least two entries!") + asserts.assert_less_equal(len(supported_modes), 255, "SupportedModes must have at most 255 entries!") + + # Check that each Mode field is unique + supported_modes_dut = [] + for m in supported_modes: + if m.mode in supported_modes_dut: + asserts.fail("SupportedModes must have unique mode values!") + else: + supported_modes_dut.append(m.mode) + + # Check that each label is unique + labels = [] + for m in supported_modes: + if m.label in labels: + asserts.fail("SupportedModes must have unique mode label values!") + else: + labels.append(m.label) + + # common mode tags + commonTags = {0x0: 'Auto', + 0x1: 'Quick', + 0x2: 'Quiet', + 0x3: 'LowNoise', + 0x4: 'LowEnergy', + 0x5: 'Vacation', + 0x6: 'Min', + 0x7: 'Max', + 0x8: 'Night', + 0x9: 'Day'} + + # kUnknownEnumValue may not be defined + try: + modeTags = [tag.value for tag in Clusters.DishwasherMode.Enums.ModeTag + if tag is not Clusters.DishwasherMode.Enums.ModeTag.kUnknownEnumValue] + except AttributeError: + modeTags = Clusters.DishwasherMode.Enums.ModeTag + + normal_present = false + for m in supported_modes: + # need at least 1 mode tag entry + asserts.assert_greater(len(m.modeTags, 0, "Must have at least one mode tag.")) + for t in m.modeTags: + # value can't exceed 16 bits + asserts.assert_true(t.value <= 0xFFFF, "Tag value is > 16 bits") + + # check that value field is as expected + is_mfg = (0x8000 <= t.value and t.value <= 0xBFFF) + asserts.assert_true(t.value in commonTags.keys() or t.value in modeTags or is_mfg, + "Found a SupportedModes entry with invalid mode tag value!") + + # is this a normal tag? (need at least 1) + if t.value == Clusters.DishwasherMode.Enums.ModeTag.kNormal: + normal_present = True + + # need at least one mode with the normal tag + asserts.assert_true(normal_present, "The Supported Modes does not have an entry of Normal(0x4000)") + + self.step(3) + current_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + + logging.info("CurrentMode: %s" % (current_mode)) + asserts.assert_true(current_mode in supported_modes_dut, "CurrentMode is not a supported mode!") if __name__ == "__main__": default_matter_test_main()