Skip to content

Commit 7dd6b4b

Browse files
Fix PICS code, add a test that was missed (project-chip#34713)
* Fix PICS code, add a test that was missed * Editorial fix --------- Co-authored-by: raju-apple <84206864+raju-apple@users.noreply.github.com>
1 parent 4c1f325 commit 7dd6b4b

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

src/python_testing/TC_TSTAT_4_2.py

+29-9
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ def steps_TC_TSTAT_4_2(self) -> list[TestStep]:
117117
TestStep("1", "Commissioning, already done",
118118
is_commissioning=True),
119119
TestStep("2", "TH writes to the Presets attribute without calling the StartPresetsSchedulesEditRequest command",
120-
"Verify that the Presets attribute was not updated."),
120+
" Verify that the write request returns INVALID_IN_STATE error since the client didn't send a request to edit the presets by calling StartPresetsSchedulesEditRequest command."),
121121
TestStep("3", "TH writes to the Presets attribute after calling the StartPresetsSchedulesEditRequest command but doesn't call CommitPresetsSchedulesRequest to commit",
122-
"Verify that the Presets attribute was not updated."),
122+
"Verify that the Presets attribute was not updated since CommitPresetsSchedulesRequest command was not called."),
123123
TestStep("4", "TH writes to the Presets attribute after calling the StartPresetsSchedulesEditRequest command and calls CommitPresetsSchedulesRequest to commit",
124-
"Verify that the Presets attribute was updated."),
124+
"Verify that the Presets attribute was updated with new presets."),
125125
TestStep("5", "TH writes to the Presets attribute with a built-in preset removed",
126126
"Verify that the CommitPresetsSchedulesRequest returned UNSUPPORTED_ACCESS (0x7e)."),
127127
TestStep("6", "TH writes to the Presets attribute with a preset removed whose handle matches the value in the ActivePresetHandle attribute",
@@ -132,11 +132,13 @@ def steps_TC_TSTAT_4_2(self) -> list[TestStep]:
132132
"Verify that the CommitPresetsSchedulesRequest returned CONSTRAINT_ERROR (0x87)."),
133133
TestStep("9", "TH writes to the Presets attribute with a new preset having a preset handle that doesn't exist in the Presets attribute",
134134
"Verify that the CommitPresetsSchedulesRequest returned NOT_FOUND (0x8b)."),
135-
TestStep("10", "TH writes to the Presets attribute with a non built-in preset modified to be built-in",
135+
TestStep("10", "TH writes to the Presets attribute with duplicate presets",
136+
"Verify that the CommitPresetsSchedulesRequest returned CONSTRAINT_ERROR (0x87)."),
137+
TestStep("11", "TH writes to the Presets attribute with a non built-in preset modified to be built-in",
136138
"Verify that the CommitPresetsSchedulesRequest returned UNSUPPORTED_ACCESS (0x7e)."),
137-
TestStep("11", "TH writes to the Presets attribute with a preset that doesn't support names in the PresetTypeFeatures bitmap but has a name",
139+
TestStep("12", "TH writes to the Presets attribute with a preset that doesn't support names in the PresetTypeFeatures bitmap but has a name",
138140
"Verify that the CommitPresetsSchedulesRequest returned CONSTRAINT_ERROR (0x87)."),
139-
TestStep("12", "TH writes to the Presets attribute but calls the CancelPresetsSchedulesEditRequest command to cancel the edit request",
141+
TestStep("13", "TH writes to the Presets attribute but calls the CancelPresetsSchedulesEditRequest command to cancel the edit request",
140142
"Verify that the edit request was cancelled"),
141143
]
142144

@@ -161,7 +163,7 @@ async def test_TC_TSTAT_4_2(self):
161163
asserts.assert_true(status_ok, "Presets write did not return InvalidInState as expected")
162164

163165
self.step("3")
164-
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C07.Rsp") and self.check_pics("TSTAT.S.C09.Rsp")):
166+
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C07.Rsp")):
165167
await self.send_edit_preset_request_command()
166168

167169
# Write to the presets attribute after calling StartPresetsSchedulesEditRequest command
@@ -292,6 +294,24 @@ async def test_TC_TSTAT_4_2(self):
292294
# Send the StartPresetsSchedulesEditRequest command
293295
await self.send_edit_preset_request_command()
294296

297+
# Write to the presets attribute after adding a duplicate preset with handle (b'\x03')
298+
test_presets = copy.deepcopy(new_presets_with_handle)
299+
test_presets.append(cluster.Structs.PresetStruct(
300+
presetHandle=b'\x03', presetScenario=cluster.Enums.PresetScenarioEnum.kSleep, name="Sleep", coolingSetpoint=2700, heatingSetpoint=1900, builtIn=False))
301+
302+
status = await self.write_presets(endpoint=endpoint, presets=test_presets)
303+
status_ok = (status == Status.Success)
304+
asserts.assert_true(status_ok, "Presets write did not return Success as expected")
305+
306+
# Send the CommitPresetsSchedulesRequest command and expect ConstraintError
307+
await self.send_commit_preset_request_command(expected_status=Status.ConstraintError)
308+
309+
self.step("11")
310+
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C07.Rsp") and self.check_pics("TSTAT.S.C09.Rsp")):
311+
312+
# Send the StartPresetsSchedulesEditRequest command
313+
await self.send_edit_preset_request_command()
314+
295315
# Write to the presets attribute after setting the builtIn flag to True for preset with handle (b'\x03')
296316
test_presets = copy.deepcopy(new_presets_with_handle)
297317
test_presets[2].builtIn = True
@@ -303,7 +323,7 @@ async def test_TC_TSTAT_4_2(self):
303323
# Send the CommitPresetsSchedulesRequest command and expect UnsupportedAccess
304324
await self.send_commit_preset_request_command(expected_status=Status.UnsupportedAccess)
305325

306-
self.step("11")
326+
self.step("12")
307327
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C07.Rsp") and self.check_pics("TSTAT.S.C09.Rsp")):
308328

309329
# Send the StartPresetsSchedulesEditRequest command
@@ -320,7 +340,7 @@ async def test_TC_TSTAT_4_2(self):
320340
# Send the CommitPresetsSchedulesRequest command and expect ConstraintError
321341
await self.send_commit_preset_request_command(expected_status=Status.ConstraintError)
322342

323-
self.step("12")
343+
self.step("13")
324344
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C07.Rsp") and self.check_pics("TSTAT.S.C09.Rsp")):
325345

326346
# Send the StartPresetsSchedulesEditRequest command

0 commit comments

Comments
 (0)