Skip to content

Commit 86d7929

Browse files
restyled-commitsPeterC1965
authored andcommitted
Restyled by autopep8
1 parent d176136 commit 86d7929

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

src/python_testing/TC_DEM_2_2.py

+26-13
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def steps_TC_DEM_2_2(self) -> list[TestStep]:
5454
TestStep("3a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
5555
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."),
5656
TestStep("3c", "TH reads OptOutState attribute. Verify value is 0x00 (NoOptOut)"),
57-
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"),
57+
TestStep(
58+
"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"),
5859
TestStep("4a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
5960
TestStep("4b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
6061
TestStep("5", "TH sends CancelPowerAdjustRequest. Verify Command response is Success and Event DEM.S.E01(PowerAdjustEnd) sent with Cause=Cancelled"),
@@ -65,23 +66,27 @@ def steps_TC_DEM_2_2(self) -> list[TestStep]:
6566
TestStep("8", "TH sends PowerAdjustRequest with Power=OverallMinPower Duration=OverallMaxDuration+1 Cause=LocalOptimization. Verify Command response is ConstraintError"),
6667
TestStep("9", "TH sends PowerAdjustRequest with Power=OverallMinPower-1 Duration=OverallMaxDuration Cause=LocalOptimization. Verify Command response is ConstraintError"),
6768
TestStep("10", "TH sends PowerAdjustRequest with Power=OverallMaxPower Duration=OverallMinDuration-1 Cause=LocalOptimization. Verify Command response is ConstraintError"),
68-
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"),
69+
TestStep(
70+
"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"),
6971
TestStep("11a", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
70-
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"),
72+
TestStep(
73+
"12", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=GridOptimization. Verify Command response is Success and no event sent"),
7174
TestStep("12a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
7275
TestStep("12b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=GridOptimizationAdjustment."),
7376
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"),
7477
TestStep("13a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
7578
TestStep("13b", "TH reads OptOutState attribute. Verify value is 0x02 (LocalOptOut)"),
76-
TestStep("14", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is ConstraintError"),
79+
TestStep(
80+
"14", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization. Verify Command response is ConstraintError"),
7781
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"),
7882
TestStep("15a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
7983
TestStep("15b", "TH reads OptOutState attribute. Verify value is 0x03 (OptOut)"),
8084
TestStep("15c", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=NoAdjustment."),
8185
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"),
8286
TestStep("16a", "TH reads ESAState attribute. Verify value is 0x01 (Online)"),
8387
TestStep("16b", "TH reads OptOutState attribute. Verify value is 0x00 (NoOptOut)"),
84-
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"),
88+
TestStep(
89+
"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"),
8590
TestStep("17a", "TH reads ESAState attribute. Verify value is 0x04 (PowerAdjustActive)"),
8691
TestStep("17b", "TH reads PowerAdjustmentCapability attribute. Value has to include Cause=LocalOptimizationAdjustment."),
8792
TestStep("18", "Wait 10 seconds. Event DEM.S.E01(PowerAdjustEnd) sent with Cause=NormalCompletion, Duration=10s, EnergyUse= a valid value"),
@@ -126,7 +131,8 @@ async def test_TC_DEM_2_2(self):
126131
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
127132
asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1)
128133
logging.info(powerAdjustCapabilityStruct)
129-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
134+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
135+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
130136

131137
# we should expect powerAdjustCapabilityStruct to have multiple entries with different max powers, min powers, max and min durations
132138
found_min_power = sys.maxsize
@@ -164,7 +170,8 @@ async def test_TC_DEM_2_2(self):
164170
self.step("4b")
165171
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
166172
asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1)
167-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
173+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
174+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
168175

169176
self.step("5")
170177
await self.send_cancel_power_adjustment_command()
@@ -174,7 +181,8 @@ async def test_TC_DEM_2_2(self):
174181
self.step("5a")
175182
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
176183
asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1)
177-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
184+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
185+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
178186

179187
self.step("5b")
180188
await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline)
@@ -217,7 +225,8 @@ async def test_TC_DEM_2_2(self):
217225
self.step("11a")
218226
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
219227
asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1)
220-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
228+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
229+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
221230

222231
self.step("12")
223232
await self.send_power_adjustment_command(power=max_power,
@@ -233,7 +242,8 @@ async def test_TC_DEM_2_2(self):
233242
self.step("12b")
234243
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
235244
asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1)
236-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kGridOptimizationAdjustment)
245+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
246+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kGridOptimizationAdjustment)
237247

238248
self.step("13")
239249
await self.send_test_event_trigger_user_opt_out_local()
@@ -270,7 +280,8 @@ async def test_TC_DEM_2_2(self):
270280

271281
self.step("15c")
272282
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
273-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
283+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
284+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
274285

275286
self.step("16")
276287
await self.send_test_event_trigger_user_opt_out_clear_all()
@@ -292,7 +303,8 @@ async def test_TC_DEM_2_2(self):
292303

293304
self.step("17b")
294305
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
295-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
306+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
307+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment)
296308

297309
self.step("18")
298310
time.sleep(10)
@@ -302,7 +314,8 @@ async def test_TC_DEM_2_2(self):
302314

303315
self.step("18b")
304316
powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability")
305-
asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
317+
asserts.assert_equal(powerAdjustCapabilityStruct.cause,
318+
Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment)
306319

307320
self.step("19")
308321
await self.send_test_event_trigger_power_adjustment_clear()

src/python_testing/TC_DEM_Utils.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ async def send_cancel_power_adjustment_command(self, endpoint: int = None, timed
5858
expected_status: Status = Status.Success):
5959
try:
6060
await self.send_single_cmd(cmd=Clusters.DeviceEnergyManagement.Commands.CancelPowerAdjustRequest(),
61-
endpoint=endpoint,
62-
timedRequestTimeoutMs=timedRequestTimeoutMs)
61+
endpoint=endpoint,
62+
timedRequestTimeoutMs=timedRequestTimeoutMs)
6363

6464
asserts.assert_equal(expected_status, Status.Success)
6565

@@ -218,6 +218,3 @@ async def send_test_event_trigger_forecast(self):
218218

219219
async def send_test_event_trigger_forecast_clear(self):
220220
await self.send_test_event_triggers(eventTrigger=0x0098000000000010)
221-
222-
223-

src/python_testing/matter_testing_support.py

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def wait_for_event_expect_no_report(self, timeout: int = 10):
275275

276276
asserts.fail(f"Event reported when not expected {res}")
277277

278+
278279
class InternalTestRunnerHooks(TestRunnerHooks):
279280

280281
def start(self, count: int):

0 commit comments

Comments
 (0)