Skip to content

Commit

Permalink
Remove and rework tests per comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbultman committed May 3, 2024
1 parent 8921f91 commit a81855c
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 102 deletions.
22 changes: 0 additions & 22 deletions src/app/tests/suites/certification/Test_TC_DISHM_1_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
170 changes: 90 additions & 80 deletions src/python_testing/TC_DISHM_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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()

0 comments on commit a81855c

Please sign in to comment.