@@ -499,49 +499,28 @@ async def test_TC_TSTAT_4_2(self):
499
499
if totalExpectedPresetsLength > numberOfPresetsSupported :
500
500
testPresets = []
501
501
for presetType in presetTypes :
502
- didCopyPreset = False
503
- isBuiltInPreset = False
504
502
scenario = presetType .presetScenario
505
503
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
511
507
for preset in presets :
512
508
if scenario == preset .presetScenario :
513
509
testPresets .append (preset )
514
- didCopyPreset = True
515
- isBuiltInPreset = True
516
- break
510
+ + + presetsAddedForScenario
517
511
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 :
530
513
testPresets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = scenario ,
531
514
name = "Preset" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
515
+ + + presetsAddedForScenario
532
516
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 ()
540
519
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 )
542
521
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 ()
545
524
else :
546
525
logger .info (
547
526
"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