Skip to content

Commit

Permalink
Cancel subscriptions at the end of the test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterC1965 committed Aug 22, 2024
1 parent 18081b4 commit d58723f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/python_testing/TC_DEM_2_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def steps_TC_DEM_2_10(self) -> list[TestStep]:
"Verify DUT responds w/ status SUCCESS(0x00)"),
TestStep("8", "TH counts all report transactions with an attribute report for the Forecast attribute over the next Forecast.Slots[0].MinDurationAdjustment}",
"TH verifies that numberOfReportsReceived <= 2 + Forecast.Slots[0].MinDurationAdjustment}"),
TestStep("9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TESTEVENT_TRIGGERKEY and EventTrigger field set to PIXIT.DEM.TESTEVENTTRIGGER for Forecast Adjustment Test Event Clear",
TestStep("9", "Cancel the subscription to the Forecast attribute",
"The subscription is cancelled successfully"),
TestStep("10", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TESTEVENT_TRIGGERKEY and EventTrigger field set to PIXIT.DEM.TESTEVENTTRIGGER for Forecast Adjustment Test Event Clear",
"Verify DUT responds w/ status SUCCESS(0x00)"),
]

Expand Down Expand Up @@ -123,7 +125,7 @@ async def test_TC_DEM_2_10(self):

self.step("5")
sub_handler = ClusterAttributeChangeAccumulator(Clusters.DeviceEnergyManagement)
await sub_handler.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint)
await sub_handler.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint, keepSubscriptions=False)
sub_handler.reset()

self.step("6")
Expand All @@ -143,11 +145,14 @@ async def test_TC_DEM_2_10(self):
time.sleep(forecast.slots[0].minDurationAdjustment)

count = sub_handler.attribute_report_counts[Clusters.DeviceEnergyManagement.Attributes.Forecast]
logging.info(f"Number of Forecast updates {count}")
asserts.assert_less_equal(count, 10, "More than 10 reports received")

self.step("9")
await self.send_test_event_trigger_forecast_adjustment_clear()
sub_handler.cancel()

self.step("10")
await self.send_test_event_trigger_forecast_adjustment_clear()

if __name__ == "__main__":
default_matter_test_main()

0 comments on commit d58723f

Please sign in to comment.