Skip to content

Commit

Permalink
Restyled by autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and PeterC1965 committed Jul 8, 2024
1 parent 9d9e6ab commit 79ab87f
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 152 deletions.
4 changes: 2 additions & 2 deletions src/python_testing/TC_DEM_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def test_TC_DEM_2_3(self):
asserts.assert_not_equal(forecast, NullValue)
if forecast is not NullValue:
asserts.assert_less_equal(forecast.earliestStartTime, forecast.startTime,
f"Expected forecast earliestStartTime {forecast.earliestStartTime} to be <= startTime {forecast.startTime}")
f"Expected forecast earliestStartTime {forecast.earliestStartTime} to be <= startTime {forecast.startTime}")
asserts.assert_greater_equal(forecast.latestEndTime, forecast.endTime,
f"Expected forecast latestEndTime {forecast.latestEndTime} to be >= endTime {forecast.endTime}")
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization,
Expand Down Expand Up @@ -198,7 +198,7 @@ async def test_TC_DEM_2_3(self):
asserts.assert_greater_equal(forecast4.latestEndTime, forecast4.endTime,
f"Expected forecast latestEndTime {forecast4.latestEndTime} to be >= endTime {forecast4.endTime}")
asserts.assert_equal(forecast4.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization,
f"Expected forecastUpdateReason {forecast4.forecastUpdateReason} to be == InternalOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization}")
f"Expected forecastUpdateReason {forecast4.forecastUpdateReason} to be == InternalOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization}")

self.step("9")
await self.send_start_time_adjust_request_command(requestedStartTime=forecast4.startTime+forecast4.latestEndTime - forecast4.endTime,
Expand Down
49 changes: 32 additions & 17 deletions src/python_testing/TC_DEM_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,56 @@ def steps_TC_DEM_2_4(self) -> list[TestStep]:
TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster. Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"),
TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event"),
TestStep("3a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("3b", "TH reads Forecast. Value has to include IsPausable=True, slot[0].SlotIsPausable=True, slot[0].MinPauseDuration>1, slot[0].MaxPauseDuration>1, slot[1].SlotIsPausable=False, ActiveSlotNumber=0, and ForecastUpdateReason=Internal Optimization"),
TestStep(
"3b", "TH reads Forecast. Value has to include IsPausable=True, slot[0].SlotIsPausable=True, slot[0].MinPauseDuration>1, slot[0].MaxPauseDuration>1, slot[1].SlotIsPausable=False, ActiveSlotNumber=0, and ForecastUpdateReason=Internal Optimization"),
TestStep("3c", "TH reads OptOutState. Verify value is 0x00 (NoOptOut)"),
TestStep("4", "TH sends PauseRequest with Duration=MinPauseDuration-1 from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep(
"4", "TH sends PauseRequest with Duration=MinPauseDuration-1 from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep("4a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("5", "TH sends PauseRequest with Duration=MaxPauseDuration+1 from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep(
"5", "TH sends PauseRequest with Duration=MaxPauseDuration+1 from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep("5a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("6", "DGGEN.S.C00.Rsp(TestEventTrigger). TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event"),
TestStep("6a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("6b", "TH reads OptOutState. Verify value is 0x02 (GridOptOut)"),
TestStep("7", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=GridOptimization. Command rejected"),
TestStep(
"7", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=GridOptimization. Command rejected"),
TestStep("7a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("8", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep(
"8", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep("8a", "TH reads ESAState. Verify value is 0x05 (Paused)"),
TestStep("9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event. Event {PICS_S}.E03(Resumed) sent with Cause=3 (UserOptOut)"),
TestStep(
"9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event. Event {PICS_S}.E03(Resumed) sent with Cause=3 (UserOptOut)"),
TestStep("9a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("9b", "TH reads OptOutState. Verify value is 0x03 (OptOut)"),
TestStep("9c", "TH reads Forecast. Value has to include ForecastUpdateReason=Internal Optimization"),
TestStep("10", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear"),
TestStep("10a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("10b", "TH reads OptOutState. Verify value is 0x00 (NoOptOut)"),
TestStep("11", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep(
"11", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep("11a", "TH reads ESAState. Verify value is 0x05 (Paused)"),
TestStep("11b", "TH reads Forecast. Value has to include ForecastUpdateReason=Local Optimization"),
TestStep("12", "TH sends ResumeRequest. Event {PICS_S}.E03(Resumed) sent with Cause=4 (Cancelled)"),
TestStep("12a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("12b", "TH reads Forecast. Value has to include IsPausable=True, slot[0].SlotIsPausable=True, slot[0].MinPauseDuration>1, slot[0].MaxPauseDuration>1, slot[1].SlotIsPausable=False, ActiveSlotNumber=0, ForecastUpdateReason=Internal Optimization"),
TestStep("13", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep(
"12b", "TH reads Forecast. Value has to include IsPausable=True, slot[0].SlotIsPausable=True, slot[0].MinPauseDuration>1, slot[0].MaxPauseDuration>1, slot[1].SlotIsPausable=False, ActiveSlotNumber=0, ForecastUpdateReason=Internal Optimization"),
TestStep(
"13", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep("13a", "TH reads ESAState. Verify value is 0x05 (Paused)"),
TestStep("13b", "TH reads Forecast. Value has to include ForecastUpdateReason=Local Optimization"),
TestStep("14", "TH sends ResumeRequest. Event {PICS_S}.E03(Resumed) sent with Cause=4 (Cancelled)"),
TestStep("14a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("15", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep(
"15", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Event {PICS_S}.E02(Paused) sent"),
TestStep("15a", "TH reads ESAState. Verify value is 0x05 (Paused)"),
TestStep("16", "Wait for minPauseDuration. Event {PICS_S}.E03(Resumed) sent with Cause=0 (NormalCompletion)"),
TestStep("16a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Next Slot."),
TestStep("17a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("17b", "TH reads Forecast. Value has to include ActiveSlotNumber=1"),
TestStep("18", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep(
"18", "TH sends PauseRequest with Duration=MinPauseDuration from Forecast for slot[0], Cause=LocalOptimization. Command rejected"),
TestStep("18a", "TH reads ESAState. Verify value is 0x01 (Online)"),
TestStep("19", "TH sends ResumeRequest. Command rejected"),
TestStep("20", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Clear."),
Expand Down Expand Up @@ -129,7 +140,7 @@ async def test_TC_DEM_2_4(self):

if forecast is not NullValue:
asserts.assert_less_equal(forecast.earliestStartTime, forecast.startTime,
f"Expected forecast earliestStartTime {forecast.earliestStartTime} to be <= startTime {forecast.startTime}")
f"Expected forecast earliestStartTime {forecast.earliestStartTime} to be <= startTime {forecast.startTime}")
asserts.assert_greater_equal(forecast.latestEndTime, forecast.endTime,
f"Expected forecast latestEndTime {forecast.latestEndTime} to be >= endTime {forecast.endTime}")
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization,
Expand Down Expand Up @@ -210,7 +221,8 @@ async def test_TC_DEM_2_4(self):
forecast = await self.read_dem_attribute_expect_success(attribute="Forecast")

asserts.assert_not_equal(forecast, NullValue)
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization)
asserts.assert_equal(forecast.forecastUpdateReason,
Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization)

self.step("10")
await self.send_test_event_trigger_user_opt_out_clear_all()
Expand All @@ -231,7 +243,8 @@ async def test_TC_DEM_2_4(self):

self.step("11b")
forecast = await self.read_dem_attribute_expect_success(attribute="Forecast")
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)
asserts.assert_equal(forecast.forecastUpdateReason,
Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)

self.step("12")
await self.send_resume_request_command()
Expand All @@ -249,20 +262,21 @@ async def test_TC_DEM_2_4(self):
asserts.assert_equal(forecast.slots[0].slotIsPausable, True)
asserts.assert_equal(forecast.slots[1].slotIsPausable, False)
asserts.assert_equal(forecast.activeSlotNumber, 0)
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)
asserts.assert_equal(forecast.forecastUpdateReason,
Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)

self.step("13")
await self.send_pause_request_command(forecast.slots[0].minPauseDuration,
Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization)
event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Paused)


self.step("13a")
await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPaused)

self.step("13b")
forecast = await self.read_dem_attribute_expect_success(attribute="Forecast")
asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)
asserts.assert_equal(forecast.forecastUpdateReason,
Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization)

self.step("14")
await self.send_resume_request_command()
Expand Down Expand Up @@ -312,5 +326,6 @@ async def test_TC_DEM_2_4(self):
self.step("20")
await self.send_test_event_trigger_user_opt_out_clear_all()


if __name__ == "__main__":
default_matter_test_main()
Loading

0 comments on commit 79ab87f

Please sign in to comment.