Skip to content

Commit efa0f3d

Browse files
committed
Changes per comments
1 parent 4a87cc7 commit efa0f3d

File tree

1 file changed

+59
-33
lines changed

1 file changed

+59
-33
lines changed

src/python_testing/TC_DISHM_2_1.py

+59-33
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import logging
1919

2020
import chip.clusters as Clusters
21-
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches
21+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
2222
from mobly import asserts
2323

2424

@@ -34,6 +34,34 @@ async def send_change_to_mode_cmd(self, newMode) -> Clusters.Objects.DishwasherM
3434
"Unexpected return type for ChangeToMode")
3535
return ret
3636

37+
def desc_TC_DISHM_2_1(self) -> str:
38+
return "[TC-DISHM-2.1] Change to Mode functionality with DUT as Server"
39+
40+
def steps_TC_DISHM_2_1(self) -> list[TestStep]:
41+
steps = [
42+
TestStep(1, "Commissioning, already done", is_commissioning=True),
43+
TestStep(2, "TH reads from the DUT the SupportedModes attribute."),
44+
TestStep(3, "TH reads from the DUT the CurrentMode attribute."),
45+
TestStep(4, "TH sends a ChangeToMode command to the DUT with NewMode set to old_current_mode_dut"),
46+
TestStep(5, "Manually put the device in a state from which it will FAIL to transition to PIXIT.DISHM.MODE_CHANGE_FAIL"),
47+
TestStep(6, "TH reads from the DUT the CurrentMode attribute."),
48+
TestStep(7, "TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.DISHM.MODE_CHANGE_FAIL"),
49+
TestStep(8, "TH reads from the DUT the CurrentMode attribute."),
50+
TestStep(9, "Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.DISHM.MODE_CHANGE_OK"),
51+
TestStep(10, "TH reads from the DUT the CurrentMode attribute."),
52+
TestStep(11, "TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.DISHM.MODE_CHANGE_OK"),
53+
TestStep(12, "TH reads from the DUT the CurrentMode attribute."),
54+
TestStep(13, "TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th"),
55+
TestStep(14, "TH reads from the DUT the CurrentMode attribute."),
56+
]
57+
return steps
58+
59+
def pics_TC_DISHM_2_1(self) -> list[str]:
60+
pics = [
61+
"DISHM.S",
62+
]
63+
return pics
64+
3765
@async_test_body
3866
async def test_TC_DISHM_2_1(self):
3967

@@ -57,23 +85,23 @@ async def test_TC_DISHM_2_1(self):
5785

5886
attributes = Clusters.DishwasherMode.Attributes
5987

60-
self.print_step(1, "Commissioning, already done")
88+
self.step(1)
6189

62-
self.print_step(2, "Read SupportedModes attribute")
90+
self.step(2)
91+
# read the supported modes
6392
supported_modes = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.SupportedModes)
64-
6593
logging.info("SupportedModes: %s" % (supported_modes))
66-
94+
# need at least 2 modes
6795
asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least two entries!")
68-
96+
# save them
6997
supported_modes_dut = [m.mode for m in supported_modes]
98+
# check that mode change fail is present
99+
asserts.assert_true(self.modeFail in supported_modes_dut, "SupportedModes must include MODE_CHANGE_FAIL")
70100

71-
self.print_step(3, "Read CurrentMode attribute")
72-
101+
self.step(3)
102+
# Read the current mode
73103
old_current_mode_dut = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
74-
75104
logging.info("CurrentMode: %s" % (old_current_mode_dut))
76-
77105
# pick a value that's not in the list of supported modes
78106
invalid_mode_th = max(supported_modes_dut) + 1
79107

@@ -85,73 +113,71 @@ class CommonCodes(Enum):
85113
GENERIC_FAILURE = 0x02
86114
INVALID_IN_MODE = 0x03
87115

88-
self.print_step(4, "Send ChangeToMode command with NewMode set to %d" % (old_current_mode_dut))
89-
116+
self.step(4)
117+
logging.info("Send ChangeToMode command with NewMode set to %d" % (old_current_mode_dut))
90118
ret = await self.send_change_to_mode_cmd(newMode=old_current_mode_dut)
91119
asserts.assert_true(ret.status == CommonCodes.SUCCESS.value, "Changing the mode to the current mode should be a no-op")
92120

93121
if self.check_pics("DISHM.S.M.CAN_TEST_MODE_FAILURE"):
94-
self.print_step(5, "Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modeFail))
122+
self.step(5)
123+
logging.info("Manually put the device in a state from which it will FAIL to transition to mode %d" % (self.modeFail))
95124
input("Press Enter when done.\n")
96125

97-
self.print_step(6, "Read CurrentMode attribute")
126+
self.step(6)
98127
old_current_mode_dut = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
99-
100128
logging.info("CurrentMode: %s" % (old_current_mode_dut))
101129

102-
self.print_step(7, "Send ChangeToMode command with NewMode set to %d" % (self.modeFail))
130+
self.step(7)
131+
logging.info("Send ChangeToMode command with NewMode set to %d" % (self.modeFail))
103132

104133
ret = await self.send_change_to_mode_cmd(newMode=self.modeFail)
105134
st = ret.status
106135
logging.info("ChangeToMode Status: %s" % (ret.status))
107-
is_mfg_code = st in range(0x80, 0xC0)
136+
is_mfg_code = st in range(0x80, 0xBF)
108137
is_err_code = (st == CommonCodes.GENERIC_FAILURE.value) or (st == CommonCodes.INVALID_IN_MODE.value) or is_mfg_code
109138
asserts.assert_true(
110139
is_err_code, "Changing to mode %d must fail due to the current state of the device" % (self.modeFail))
111140
logging.info("Status Text: %s" % (ret.statusText))
112141
st_text_len = len(ret.statusText)
113142
asserts.assert_true(st_text_len in range(1, 65), "StatusText length (%d) must be between 1 and 64" % (st_text_len))
114143

115-
self.print_step(8, "Read CurrentMode attribute")
144+
self.step(8)
116145
current_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
117-
118146
logging.info("CurrentMode: %s" % (current_mode))
119-
120147
asserts.assert_true(current_mode == old_current_mode_dut, "CurrentMode changed after failed ChangeToMode command!")
148+
else:
149+
for x in range(5, 9):
150+
self.skip(x)
121151

122-
self.print_step(9, "Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self.modeOk))
152+
self.step(9)
153+
logging.info("Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d" % (self.modeOk))
123154
input("Press Enter when done.\n")
124155

125-
self.print_step(10, "Read CurrentMode attribute")
156+
self.step(10)
126157
old_current_mode_dut = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
127-
128158
logging.info("CurrentMode: %s" % (old_current_mode_dut))
129159

130-
self.print_step(11, "Send ChangeToMode command with NewMode set to %d" % (self.modeOk))
131-
160+
self.step(11)
161+
logging.info("Send ChangeToMode command with NewMode set to %d" % (self.modeOk))
132162
ret = await self.send_change_to_mode_cmd(newMode=self.modeOk)
133163
asserts.assert_true(ret.status == CommonCodes.SUCCESS.value,
134164
"Changing to mode %d must succeed due to the current state of the device" % (self.modeOk))
135165

136-
self.print_step(12, "Read CurrentMode attribute")
166+
self.step(12)
137167
current_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
138-
139168
logging.info("CurrentMode: %s" % (current_mode))
140-
141169
asserts.assert_true(current_mode == self.modeOk,
142170
"CurrentMode doesn't match the argument of the successful ChangeToMode command!")
143171

144-
self.print_step(13, "Send ChangeToMode command with NewMode set to %d" % (invalid_mode_th))
145-
172+
self.step(13)
173+
logging.info("Send ChangeToMode command with NewMode set to %d" % (invalid_mode_th))
146174
ret = await self.send_change_to_mode_cmd(newMode=invalid_mode_th)
147175
asserts.assert_true(ret.status == CommonCodes.UNSUPPORTED_MODE.value,
148176
"Attempt to change to invalid mode %d didn't fail as expected" % (invalid_mode_th))
149177

150-
self.print_step(14, "Read CurrentMode attribute")
178+
self.step(14)
151179
current_mode = await self.read_mode_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
152-
153180
logging.info("CurrentMode: %s" % (current_mode))
154-
155181
asserts.assert_true(current_mode == self.modeOk, "CurrentMode changed after failed ChangeToMode command!")
156182

157183

0 commit comments

Comments
 (0)