Skip to content

Commit 5fd85ad

Browse files
committed
Add test for individual preset scenario limits
1 parent 25376bf commit 5fd85ad

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/python_testing/TC_TSTAT_4_2.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ async def test_TC_TSTAT_4_2(self):
619619
if len(unavailableScenarios) > 0:
620620
test_presets = current_presets.copy()
621621
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=unavailableScenarios[0],
622-
name="Preset", coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
622+
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
623623

624624
# Send the AtomicRequest begin command
625625
await self.send_atomic_request_begin_command()
@@ -635,6 +635,29 @@ async def test_TC_TSTAT_4_2(self):
635635
self.step("18")
636636
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
637637

638+
# Generate list of tuples of scenarios and number of remaining presets per scenario allowed
639+
presetScenarioHeadroom = list([presetType.presetScenario,
640+
presetType.numberOfPresets - presetScenarioCounts.get(presetType.presetScenario, 0)] for presetType in presetTypes)
641+
642+
if len(presetScenarioHeadroom) > 0:
643+
# Find the preset scenario with the fewest number of remaining allowed presets
644+
presetScenarioHeadroom = sorted(presetScenarioHeadroom, key=lambda diff: diff[1])
645+
presetScenario = presetScenarioHeadroom[0][0]
646+
headroom = presetScenarioHeadroom[0][1]
647+
648+
# Add one more preset than is allowed by the preset type
649+
test_presets = copy.deepcopy(current_presets)
650+
for _ in range(0, headroom + 1):
651+
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=presetScenario,
652+
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
653+
654+
await self.send_atomic_request_begin_command()
655+
656+
await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ResourceExhausted)
657+
658+
# Clear state for next test.
659+
await self.send_atomic_request_rollback_command()
660+
638661
# Calculate the length of the Presets list that could be created using the preset scenarios in PresetTypes and numberOfPresets supported for each scenario.
639662
totalExpectedPresetsLength = sum(presetType.numberOfPresets for presetType in presetTypes)
640663

0 commit comments

Comments
 (0)