Skip to content

Commit

Permalink
Renamed DEMBaseTest.py to TC_DEMTestBase.py so that it's grouped with…
Browse files Browse the repository at this point in the history
… the TC_DEM scripts.

Also split the expected result in the TestSteps() into 3rd 'expected' arg. Corrected some missing Verification steps.
  • Loading branch information
jamesharrow committed Jul 10, 2024
1 parent f3d6018 commit 43e1617
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 83 deletions.
File renamed without changes.
127 changes: 81 additions & 46 deletions src/python_testing/TC_DEM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import chip.clusters as Clusters
from chip.interaction_model import Status
from DEMTestBase import DEMTestBase
from TC_DEMTestBase import DEMTestBase
from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts

Expand All @@ -48,51 +48,86 @@ def pics_TC_DEM_2_2(self):
def steps_TC_DEM_2_2(self) -> list[TestStep]:
"""Execute the test steps."""
steps = [
TestStep("1", "Commissioning, already done", is_commissioning=True),
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 Power Adjustment Test Event"),
TestStep("3a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
TestStep("3b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=NoAdjustment. Note value for later. Determine the OverallMaxPower and OverallMaxDuration as the largest MaxPower and MaxDuration of the PowerAdjustStructs returned, and similarly the OverallMinPower and OverallMinDuration as the smallest of the MinPower and MinDuration values."),
TestStep("3c", "TH reads OptOutState attribute. Verify value is 0x00 (NoOptOut)"),
TestStep(
"4", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is Success and Event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("4a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
TestStep("4b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
TestStep("5", "TH sends CancelPowerAdjustRequest. Verify Command response is Success and Event DEM.S.E01(PowerAdjustEnd) sent with Cause=Cancelled"),
TestStep("5a", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=NoAdjustment."),
TestStep("5b", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
TestStep("6", "TH sends CancelPowerAdjustRequest. Verify Command response is InvalidInStateError"),
TestStep("7", "TH sends PowerAdjustRequest with Power=OverallMaxPower+1 Duration=OverallMinDuration Cause=LocalOptimization. Verify Command response is ConstraintError"),
TestStep("8", "TH sends PowerAdjustRequest with Power=OverallMinPower Duration=OverallMaxDuration+1 Cause=LocalOptimization. Verify Command response is ConstraintError"),
TestStep("9", "TH sends PowerAdjustRequest with Power=OverallMinPower-1 Duration=OverallMaxDuration Cause=LocalOptimization. Verify Command response is ConstraintError"),
TestStep("10", "TH sends PowerAdjustRequest with Power=OverallMaxPower Duration=OverallMinDuration-1 Cause=LocalOptimization. Verify Command response is ConstraintError"),
TestStep(
"11", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is Success and event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("11a", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
TestStep(
"12", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=GridOptimization. Verify Command response is Success and no event sent"),
TestStep("12a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
TestStep("12b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=GridOptimizationAdjustment."),
TestStep("13", "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. No event sent"),
TestStep("13a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
TestStep("13b", "TH reads OptOutState attribute. Verify value is 0x02 (LocalOptOut)"),
TestStep(
"14", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is ConstraintError"),
TestStep("15", "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. Event DEM.S.E01(PowerAdjustEnd) sent with Cause=UserOptOut, Duration= approx time from step 11 to step 15, EnergyUse= a valid value"),
TestStep("15a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
TestStep("15b", "TH reads OptOutState attribute. Verify value is 0x03 (OptOut)"),
TestStep("15c", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=NoAdjustment."),
TestStep("16", "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("16a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
TestStep("16b", "TH reads OptOutState attribute. Verify value is 0x00 (NoOptOut)"),
TestStep(
"17", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is Success and event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("17a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
TestStep("17b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
TestStep("18", "Wait 10 seconds. Event DEM.S.E01(PowerAdjustEnd) sent with Cause=NormalCompletion, Duration=10s, EnergyUse= a valid value"),
TestStep("18a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
TestStep("18b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=NoAdjustment."),
TestStep("19", "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 Power Adjustment Test Event Clear"),
TestStep("1", "Commissioning, already done",
is_commissioning=True),
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 Power Adjustment Test Event",
"Verify DUT responds with status SUCCESS(0x00)"),
TestStep("3a", "TH reads ESAState attribute.",
"Verify value is 0x01 (Online)"),
TestStep("3b", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=NoAdjustment. Note value for later. Determine the OverallMaxPower and OverallMaxDuration as the largest MaxPower and MaxDuration of the PowerAdjustStructs returned, and similarly the OverallMinPower and OverallMinDuration as the smallest of the MinPower and MinDuration values."),
TestStep("3c", "TH reads OptOutState attribute.",
"Verify value is 0x00 (NoOptOut)"),
TestStep("4", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.",
"Verify DUT responds with status SUCCESS(0x00) and Event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("4a", "TH reads ESAState attribute.",
"Verify value is 0x04 (PowerAdjustActive)"),
TestStep("4b", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=LocalOptimizationAdjustment."),
TestStep("5", "TH sends CancelPowerAdjustRequest.",
"Verify DUT responds with status SUCCESS(0x00) and Event DEM.S.E01(PowerAdjustEnd) sent with Cause=Cancelled"),
TestStep("5a", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=NoAdjustment."),
TestStep("5b", "TH reads ESAState attribute.",
"Verify value is 0x01 (Online)"),
TestStep("6", "TH sends CancelPowerAdjustRequest.",
"Verify DUT responds with status INVALID_IN_STATE(0xcb)"),
TestStep("7", "TH sends PowerAdjustRequest with Power=OverallMaxPower+1 Duration=OverallMinDuration Cause=LocalOptimization.",
"Verify DUT responds with status CONSTRAINT_ERROR(0x87)"),
TestStep("8", "TH sends PowerAdjustRequest with Power=OverallMinPower Duration=OverallMaxDuration+1 Cause=LocalOptimization.",
"Verify DUT responds with status CONSTRAINT_ERROR(0x87)"),
TestStep("9", "TH sends PowerAdjustRequest with Power=OverallMinPower-1 Duration=OverallMaxDuration Cause=LocalOptimization.",
"Verify DUT responds with status CONSTRAINT_ERROR(0x87)"),
TestStep("10", "TH sends PowerAdjustRequest with Power=OverallMaxPower Duration=OverallMinDuration-1 Cause=LocalOptimization.",
"Verify DUT responds with status CONSTRAINT_ERROR(0x87)"),
TestStep("11", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.",
"Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("11a", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=LocalOptimizationAdjustment."),
TestStep("12", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=GridOptimization.",
"Verify DUT responds with status SUCCESS(0x00) and no event sent"),
TestStep("12a", "TH reads ESAState attribute.",
"Verify value is 0x04 (PowerAdjustActive)"),
TestStep("12b", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=GridOptimizationAdjustment."),
TestStep("13", "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.",
"Verify DUT responds with status SUCCESS(0x00) and no event sent"),
TestStep("13a", "TH reads ESAState attribute.",
"Verify value is 0x04 (PowerAdjustActive)"),
TestStep("13b", "TH reads OptOutState attribute.",
"Verify value is 0x02 (LocalOptOut)"),
TestStep("14", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.",
"Verify DUT responds with status CONSTRAINT_ERROR(0x87)"),
TestStep("15", "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.",
"Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E01(PowerAdjustEnd) sent with Cause=UserOptOut, Duration= approx time from step 11 to step 15, EnergyUse= a valid value"),
TestStep("15a", "TH reads ESAState attribute.",
"Verify value is 0x01 (Online)"),
TestStep("15b", "TH reads OptOutState attribute.",
"Verify value is 0x03 (OptOut)"),
TestStep("15c", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=NoAdjustment."),
TestStep("16", "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",
"Verify DUT responds with status SUCCESS(0x00)"),
TestStep("16a", "TH reads ESAState attribute.",
"Verify value is 0x01 (Online)"),
TestStep("16b", "TH reads OptOutState attribute.",
"Verify value is 0x00 (NoOptOut)"),
TestStep("17", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.",
"Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"),
TestStep("17a", "TH reads ESAState attribute.",
"Verify value is 0x04 (PowerAdjustActive)"),
TestStep("17b", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=LocalOptimizationAdjustment."),
TestStep("18", "Wait 10 seconds.",
"Event DEM.S.E01(PowerAdjustEnd) sent with Cause=NormalCompletion, Duration=10s, EnergyUse= a valid value"),
TestStep("18a", "TH reads ESAState attribute.",
"Verify value is 0x01 (Online)"),
TestStep("18b", "TH reads PowerAdjustmentCapability attribute.",
"Value has to include Cause=NoAdjustment."),
TestStep("19", "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 Power Adjustment Test Event Clear",
"Verify DUT responds with status SUCCESS(0x00)"),
]

return steps
Expand Down
Loading

0 comments on commit 43e1617

Please sign in to comment.