Skip to content

Commit d116c7c

Browse files
rbultmanandy31415
andauthored
[MWOCTRL] Add constraint error checks (#32118)
* Add constraint error checks * Apply suggestions from code review Co-authored-by: Andrei Litvin <andy314@gmail.com> * Added check for exception expected --------- Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent d4a89c9 commit d116c7c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/python_testing/TC_MWOCTRL_2_2.py

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def steps_TC_MWOCTRL_2_2(self) -> list[TestStep]:
4242
TestStep(2, "Read the PowerSetting attribute"),
4343
TestStep(3, "Send the SetCookingParameters command"),
4444
TestStep(4, "Read and verify the PowerSetting attribute"),
45+
TestStep(5, "Cause constraint error response"),
4546
]
4647
return steps
4748

@@ -89,6 +90,14 @@ async def test_TC_MWOCTRL_2_2(self):
8990
powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting)
9091
asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set")
9192

93+
self.step(5)
94+
newPowerValue = 125
95+
try:
96+
await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint)
97+
asserts.assert_fail("Expected an exception but received none.")
98+
except InteractionModelError as e:
99+
asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different error.")
100+
92101

93102
if __name__ == "__main__":
94103
default_matter_test_main()

src/python_testing/TC_MWOCTRL_2_3.py

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def steps_TC_MWOCTRL_2_3(self) -> list[TestStep]:
4545
TestStep(5, "Read the PowerSetting attribute"),
4646
TestStep(6, "Send the SetCookingParameters command"),
4747
TestStep(7, "Read and verify the PowerSetting attribute"),
48+
TestStep(8, "Cause constraint error response"),
4849
]
4950
return steps
5051

@@ -109,6 +110,14 @@ async def test_TC_MWOCTRL_2_3(self):
109110
powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting)
110111
asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set")
111112

113+
self.step(8)
114+
newPowerValue = maxPowerValue+1
115+
try:
116+
await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint)
117+
asserts.assert_fail("Expected an exception but received none.")
118+
except InteractionModelError as e:
119+
asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response.")
120+
112121

113122
if __name__ == "__main__":
114123
default_matter_test_main()

0 commit comments

Comments
 (0)