@@ -186,6 +186,10 @@ def steps_TC_TSTAT_4_2(self) -> list[TestStep]:
186
186
"Verify that the write request is rejected" ),
187
187
TestStep ("16" , "TH starts an atomic write, and before it's complete, TH2 removes TH's fabric; TH2 then opens an atomic write" ,
188
188
"Verify that the atomic request is successful" ),
189
+ TestStep ("17" , "TH writes to the Presets attribute with a preset that has a presetScenario not present in PresetTypes attribute" ,
190
+ "Verify that the write request returned CONSTRAINT_ERROR (0x87)." ),
191
+ TestStep ("18" , "TH writes to the Presets attribute such that the total number of presets is greater than the number of presets supported" ,
192
+ "Verify that the AtomicRequest commit returned RESOURCE_EXHAUSTED (0x89)." ),
189
193
]
190
194
191
195
return steps
@@ -441,8 +445,44 @@ async def test_TC_TSTAT_4_2(self):
441
445
# Roll back
442
446
await self .send_atomic_request_rollback_command ()
443
447
444
- # TODO: Add tests for the total number of Presets exceeds the NumberOfPresets supported. Also Add tests for adding presets with preset scenario not present in PresetTypes.
448
+ self .step ("17" )
449
+ 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" )):
450
+ test_presets = new_presets_with_handle .copy ()
451
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = 9 ,
452
+ name = "Wake" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
453
+
454
+ # Send the AtomicRequest begin command
455
+ await self .send_atomic_request_begin_command ()
456
+
457
+ await self .write_presets (endpoint = endpoint , presets = test_presets , expected_status = Status .ConstraintError )
458
+
459
+ # Clear state for next test.
460
+ await self .send_atomic_request_rollback_command ()
461
+
462
+ self .step ("18" )
463
+ 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" )):
464
+
465
+ # Read the active preset handle attribute and verify it was updated to preset handle
466
+ presetTypes = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .PresetTypes )
467
+ logger .info (f"Rx'd PresetTypes: { presetTypes } " )
468
+
469
+ test_presets = copy .deepcopy (new_presets_with_handle )
470
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = cluster .Enums .PresetScenarioEnum .kWake ,
471
+ name = "Wake" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
472
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = cluster .Enums .PresetScenarioEnum .kVacation ,
473
+ name = "Vacation" , coolingSetpoint = 2400 , heatingSetpoint = 1800 , builtIn = False ))
474
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = cluster .Enums .PresetScenarioEnum .kGoingToSleep ,
475
+ name = "GoingToSleep" , coolingSetpoint = 2300 , heatingSetpoint = 1900 , builtIn = False ))
476
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = cluster .Enums .PresetScenarioEnum .kUserDefined ,
477
+ name = "UserDefined" , coolingSetpoint = 2300 , heatingSetpoint = 1900 , builtIn = False ))
478
+
479
+ # Send the AtomicRequest begin command
480
+ await self .send_atomic_request_begin_command ()
481
+
482
+ await self .write_presets (endpoint = endpoint , presets = test_presets )
445
483
484
+ # Send the AtomicRequest commit command and expect ResourceExhausted for presets.
485
+ await self .send_atomic_request_commit_command (expected_overall_status = Status .Failure , expected_preset_status = Status .ResourceExhausted )
446
486
447
487
if __name__ == "__main__" :
448
488
default_matter_test_main ()
0 commit comments