Skip to content

Commit 4cac87e

Browse files
committed
Fix test step 17 to find a preset scenario in PresetScenarioEnum that is not present in PresetTypes to run the test
- Fix test step 18 to build a presets list that exceeds the number of presets supported correctly
1 parent bdb91fb commit 4cac87e

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

src/python_testing/TC_TSTAT_4_2.py

+35-14
Original file line numberDiff line numberDiff line change
@@ -467,17 +467,38 @@ async def test_TC_TSTAT_4_2(self):
467467

468468
self.step("17")
469469
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")):
470-
test_presets = new_presets_with_handle.copy()
471-
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=cluster.Enums.PresetScenarioEnum.kGoingToSleep,
472-
name="Wake", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
473470

474-
# Send the AtomicRequest begin command
475-
await self.send_atomic_request_begin_command()
471+
# Read the PresetTypes to get the preset scenarios supported by the Thermostat.
472+
presetTypes = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.PresetTypes)
476473

477-
await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)
474+
scenarioNotPresent = None
478475

479-
# Clear state for next test.
480-
await self.send_atomic_request_rollback_command()
476+
# Find a preset scenario not present in PresetTypes to run this test.
477+
for scenario in cluster.Enums.PresetScenarioEnum:
478+
foundMatchingScenario = False
479+
for presetType in presetTypes:
480+
if presetType.presetScenario == scenario:
481+
foundMatchingScenario = True
482+
break
483+
if foundMatchingScenario == False:
484+
scenarioNotPresent = scenario
485+
break
486+
487+
if scenarioNotPresent == None:
488+
logger.info(
489+
"Couldn't run test step 17 since all preset types in PresetScenarioEnum are supported by this Thermostat")
490+
else:
491+
test_presets = new_presets_with_handle.copy()
492+
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenarioNotPresent,
493+
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
494+
495+
# Send the AtomicRequest begin command
496+
await self.send_atomic_request_begin_command()
497+
498+
await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)
499+
500+
# Clear state for next test.
501+
await self.send_atomic_request_rollback_command()
481502

482503
self.step("18")
483504
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")):
@@ -501,18 +522,18 @@ async def test_TC_TSTAT_4_2(self):
501522
for presetType in presetTypes:
502523
scenario = presetType.presetScenario
503524

504-
# For each scenario, copy all the existing presets that match it, then add more presets
525+
# For each supported scenario, copy all the existing presets that match it, then add more presets
505526
# until we hit the cap on the number of presets for that scenario.
506527
presetsAddedForScenario = 0
507528
for preset in presets:
508529
if scenario == preset.presetScenario:
509530
testPresets.append(preset)
510-
++presetsAddedForScenario
531+
presetsAddedForScenario = presetsAddedForScenario + 1
511532

512-
while presetsAddedForScenario < presetType.numberOfPresets:
513-
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
514-
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
515-
++presetsAddedForScenario
533+
if presetsAddedForScenario < presetType.numberOfPresets:
534+
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
535+
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
536+
presetsAddedForScenario = presetsAddedForScenario + 1
516537

517538
# Send the AtomicRequest begin command
518539
await self.send_atomic_request_begin_command()

0 commit comments

Comments
 (0)