Skip to content

Commit

Permalink
Fix test step 17 to find a preset scenario in PresetScenarioEnum that…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
nivi-apple committed Aug 28, 2024
1 parent bdb91fb commit 4cac87e
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions src/python_testing/TC_TSTAT_4_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,38 @@ async def test_TC_TSTAT_4_2(self):

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

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

await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)
scenarioNotPresent = None

# Clear state for next test.
await self.send_atomic_request_rollback_command()
# Find a preset scenario not present in PresetTypes to run this test.
for scenario in cluster.Enums.PresetScenarioEnum:
foundMatchingScenario = False
for presetType in presetTypes:
if presetType.presetScenario == scenario:
foundMatchingScenario = True
break
if foundMatchingScenario == False:
scenarioNotPresent = scenario
break

if scenarioNotPresent == None:
logger.info(
"Couldn't run test step 17 since all preset types in PresetScenarioEnum are supported by this Thermostat")
else:
test_presets = new_presets_with_handle.copy()
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenarioNotPresent,
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))

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

await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)

# Clear state for next test.
await self.send_atomic_request_rollback_command()

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

# For each scenario, copy all the existing presets that match it, then add more presets
# For each supported scenario, copy all the existing presets that match it, then add more presets
# until we hit the cap on the number of presets for that scenario.
presetsAddedForScenario = 0
for preset in presets:
if scenario == preset.presetScenario:
testPresets.append(preset)
++presetsAddedForScenario
presetsAddedForScenario = presetsAddedForScenario + 1

while presetsAddedForScenario < presetType.numberOfPresets:
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
++presetsAddedForScenario
if presetsAddedForScenario < presetType.numberOfPresets:
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
name="Preset", coolingSetpoint=2500, heatingSetpoint=1700, builtIn=False))
presetsAddedForScenario = presetsAddedForScenario + 1

# Send the AtomicRequest begin command
await self.send_atomic_request_begin_command()
Expand Down

0 comments on commit 4cac87e

Please sign in to comment.