Skip to content

Commit

Permalink
Add WHM event test support
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterC1965 committed Aug 13, 2024
1 parent 95dcc6c commit 382fb34
Showing 1 changed file with 78 additions and 1 deletion.
79 changes: 78 additions & 1 deletion src/python_testing/TC_EWATERHTR_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import time

import chip.clusters as Clusters
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from chip.clusters.Types import NullValue
from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts
from TC_EWATERHTRBase import EWATERHTRBase

Expand Down Expand Up @@ -175,6 +176,12 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("1")
# Commission DUT - already done

# Subscribe to Events and when they are sent push them to a queue for checking later
events_callback = EventChangeCallback(Clusters.WaterHeaterManagement)
await events_callback.start(self.default_controller,
self.dut_node_id,
self.matter_test_config.endpoint)

self.step("2")
await self.check_test_event_triggers_enabled()

Expand Down Expand Up @@ -235,6 +242,16 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("8b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostStarted)
asserts.assert_equal(event_data.boostInfo.duration, 5)
asserts.assert_equal(event_data.boostInfo.oneShot, True)
asserts.assert_true(event_data.boostInfo.emergencyBoost is None, "emergencyBoost should be None")
asserts.assert_true(event_data.boostInfo.temporarySetpoint is None, "temporarySetpoint should be None")
asserts.assert_true(event_data.boostInfo.targetPercentage is None, "targetPercentage should be None")
asserts.assert_true(event_data.boostInfo.targetReheat is None, "targetReheat should be None")
################################################################################

self.step("9")
time.sleep(6)

Expand All @@ -245,6 +262,10 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("9b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostEnded)
################################################################################

self.step("10")
await self.send_boost_command(duration=600, one_shot=True)

Expand All @@ -256,6 +277,16 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("10b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostStarted)
asserts.assert_equal(event_data.boostInfo.duration, 600)
asserts.assert_equal(event_data.boostInfo.oneShot, True)
asserts.assert_true(event_data.boostInfo.emergencyBoost is None, "emergencyBoost should be None")
asserts.assert_true(event_data.boostInfo.temporarySetpoint is None, "temporarySetpoint should be None")
asserts.assert_true(event_data.boostInfo.targetPercentage is None, "targetPercentage should be None")
asserts.assert_true(event_data.boostInfo.targetReheat is None, "targetReheat should be None")
################################################################################

self.step("11")
await self.send_test_event_trigger_water_temperature61C_test_event()

Expand All @@ -266,6 +297,10 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("11b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostEnded)
################################################################################

self.step("12")
await self.send_test_event_trigger_water_temperature20C_test_event()

Expand All @@ -284,6 +319,16 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("13b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostStarted)
asserts.assert_equal(event_data.boostInfo.duration, 600)
asserts.assert_true(event_data.boostInfo.oneShot is None, "oneShot should be None")
asserts.assert_true(event_data.boostInfo.emergencyBoost is None, "emergencyBoost should be None")
asserts.assert_true(event_data.boostInfo.temporarySetpoint is None, "temporarySetpoint should be None")
asserts.assert_true(event_data.boostInfo.targetPercentage is None, "targetPercentage should be None")
asserts.assert_true(event_data.boostInfo.targetReheat is None, "targetReheat should be None")
################################################################################

self.step("14")
await self.send_test_event_trigger_water_temperature61C_test_event()

Expand Down Expand Up @@ -315,6 +360,10 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("16b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostEnded)
################################################################################

self.step("17")
await self.send_boost_command(duration=600, temporary_setpoint=6500)

Expand All @@ -326,6 +375,16 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("17b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostStarted)
asserts.assert_equal(event_data.boostInfo.duration, 600)
asserts.assert_true(event_data.boostInfo.oneShot is None, "oneShot should be None")
asserts.assert_true(event_data.boostInfo.emergencyBoost is None, "emergencyBoost should be None")
asserts.assert_equal(event_data.boostInfo.temporarySetpoint, 6500)
asserts.assert_true(event_data.boostInfo.targetPercentage is None, "targetPercentage should be None")
asserts.assert_true(event_data.boostInfo.targetReheat is None, "targetReheat should be None")
################################################################################

self.step("18")
await self.send_test_event_trigger_water_temperature61C_test_event()

Expand Down Expand Up @@ -358,6 +417,16 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("20b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kActive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostStarted)
asserts.assert_equal(event_data.boostInfo.duration, 600)
asserts.assert_true(event_data.boostInfo.oneShot is None, "oneShot should be None")
asserts.assert_true(event_data.boostInfo.emergencyBoost is None, "emergencyBoost should be None")
asserts.assert_equal(event_data.boostInfo.temporarySetpoint, 7000)
asserts.assert_true(event_data.boostInfo.targetPercentage is None, "targetPercentage should be None")
asserts.assert_true(event_data.boostInfo.targetReheat is None, "targetReheat should be None")
################################################################################

self.step("21")
await self.send_cancel_boost_command()

Expand All @@ -368,9 +437,17 @@ async def test_TC_EWATERHTR_2_2(self):
self.step("21b")
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive)

################################################################################
event_data = events_callback.wait_for_event_report(Clusters.WaterHeaterManagement.Events.BoostEnded)
################################################################################

self.step("22")
await self.send_cancel_boost_command()

################################################################################
event_data = events_callback.wait_for_event_expect_no_report()
################################################################################

self.step("23")
await self.send_test_event_trigger_basic_installation_test_event_clear()

Expand Down

0 comments on commit 382fb34

Please sign in to comment.