[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>
diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py
index abe02d8..a5484c5 100644
--- a/src/python_testing/TC_MWOCTRL_2_2.py
+++ b/src/python_testing/TC_MWOCTRL_2_2.py
@@ -42,6 +42,7 @@
TestStep(2, "Read the PowerSetting attribute"),
TestStep(3, "Send the SetCookingParameters command"),
TestStep(4, "Read and verify the PowerSetting attribute"),
+ TestStep(5, "Cause constraint error response"),
]
return steps
@@ -89,6 +90,14 @@
powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting)
asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set")
+ self.step(5)
+ newPowerValue = 125
+ try:
+ await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint)
+ asserts.assert_fail("Expected an exception but received none.")
+ except InteractionModelError as e:
+ asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different error.")
+
if __name__ == "__main__":
default_matter_test_main()
diff --git a/src/python_testing/TC_MWOCTRL_2_3.py b/src/python_testing/TC_MWOCTRL_2_3.py
index 0d34c5b..20a1e73 100644
--- a/src/python_testing/TC_MWOCTRL_2_3.py
+++ b/src/python_testing/TC_MWOCTRL_2_3.py
@@ -45,6 +45,7 @@
TestStep(5, "Read the PowerSetting attribute"),
TestStep(6, "Send the SetCookingParameters command"),
TestStep(7, "Read and verify the PowerSetting attribute"),
+ TestStep(8, "Cause constraint error response"),
]
return steps
@@ -109,6 +110,14 @@
powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting)
asserts.assert_true(powerValue == newPowerValue, "PowerSetting was not correctly set")
+ self.step(8)
+ newPowerValue = maxPowerValue+1
+ try:
+ await self.send_single_cmd(cmd=commands.SetCookingParameters(powerSetting=newPowerValue), endpoint=endpoint)
+ asserts.assert_fail("Expected an exception but received none.")
+ except InteractionModelError as e:
+ asserts.assert_equal(e.status, Status.ConstraintError, "Expected ConstraintError but received a different response.")
+
if __name__ == "__main__":
default_matter_test_main()