Skip to content

Commit bdb91fb

Browse files
Update src/python_testing/TC_TSTAT_4_2.py
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 8282355 commit bdb91fb

File tree

1 file changed

+11
-32
lines changed

1 file changed

+11
-32
lines changed

src/python_testing/TC_TSTAT_4_2.py

+11-32
Original file line numberDiff line numberDiff line change
@@ -499,49 +499,28 @@ async def test_TC_TSTAT_4_2(self):
499499
if totalExpectedPresetsLength > numberOfPresetsSupported:
500500
testPresets = []
501501
for presetType in presetTypes:
502-
didCopyPreset = False
503-
isBuiltInPreset = False
504502
scenario = presetType.presetScenario
505503

506-
# For each scenario, check if there are presets in the Presets attribute matching the scenario. If so, copy the presets into testPresets.
507-
# For built in presets, we can't add more entries since we can't add a built in preset according to the spec. For non built-in presets,
508-
# check if the total number of presets copied from the Presets attribute for each preset scenario is less than the number of presets supported
509-
# for that preset scenario. If yes, add more entries until we have reached the maximum number of presets for the scenario.
510-
# If we did not copy the presets, add entries up to the maximum number of presets supported for the preset scenario for this preset type.
504+
# For each scenario, copy all the existing presets that match it, then add more presets
505+
# until we hit the cap on the number of presets for that scenario.
506+
presetsAddedForScenario = 0
511507
for preset in presets:
512508
if scenario == preset.presetScenario:
513509
testPresets.append(preset)
514-
didCopyPreset = True
515-
isBuiltInPreset = True
516-
break
510+
++presetsAddedForScenario
517511

518-
if didCopyPreset and not isBuiltInPreset:
519-
countNumberOfPresetsAdded = 0
520-
for testPreset in testPresets:
521-
if testPreset.presetScenario == scenario:
522-
++countNumberOfPresetsAdded
523-
524-
if countNumberOfPresetsAdded < presetType.numberOfPresets:
525-
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
526-
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
527-
++countNumberOfPresetsAdded
528-
elif not didCopyPreset and not len(testPresets) > numberOfPresetsSupported:
529-
for index in range(presetType.numberOfPresets):
512+
while presetsAddedForScenario < presetType.numberOfPresets:
530513
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
531514
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
515+
++presetsAddedForScenario
532516

533-
# Since for built in presets, we can't add any more entries. That might cause the size of testPresets not to exceed the number of presets supported.
534-
# If so, skip the test.
535-
if not len(testPresets) > numberOfPresetsSupported:
536-
logger.info("Couldn't run test step 18 since we couldn't build a list that exceeds number of supported presets")
537-
else:
538-
# Send the AtomicRequest begin command
539-
await self.send_atomic_request_begin_command()
517+
# Send the AtomicRequest begin command
518+
await self.send_atomic_request_begin_command()
540519

541-
await self.write_presets(endpoint=endpoint, presets=testPresets, expected_status=Status.ResourceExhausted)
520+
await self.write_presets(endpoint=endpoint, presets=testPresets, expected_status=Status.ResourceExhausted)
542521

543-
# Clear state for next test.
544-
await self.send_atomic_request_rollback_command()
522+
# Clear state for next test.
523+
await self.send_atomic_request_rollback_command()
545524
else:
546525
logger.info(
547526
"Couldn't run test step 18 since there are not enough preset types to build a Presets list that exceeds the number of presets supported")

0 commit comments

Comments
 (0)