@@ -159,6 +159,8 @@ async def test_endpoints(self):
159
159
async def test_whole_node_with_pics (self ):
160
160
pass
161
161
162
+ # This method returns the top level pics for test_whole_node_with_pics
163
+ # It is used to test that test_whole_node_with_pics will fail since you can't have a whole node test gated on a PICS.
162
164
def pics_whole_node_with_pics (self ):
163
165
return ['EXAMPLE.S' ]
164
166
@@ -167,6 +169,8 @@ def pics_whole_node_with_pics(self):
167
169
async def test_per_endpoint_with_pics (self ):
168
170
pass
169
171
172
+ # This method returns the top level pics for test_per_endpoint_with_pics
173
+ # It is used to test that test_per_endpoint_with_pics will fail since you can't have a per endpoint test gated on a PICS.
170
174
def pics_per_endpoint_with_pics (self ):
171
175
return ['EXAMPLE.S' ]
172
176
@@ -210,7 +214,19 @@ async def test_endpoint_boolean_yes(self):
210
214
async def test_endpoint_boolean_no (self ):
211
215
pass
212
216
213
- # TODO: add test for assertions on whole node, and on each endpoint of an endpoint test
217
+ @per_endpoint_test (has_cluster (Clusters .OnOff ))
218
+ async def test_fail_on_ep0 (self ):
219
+ if self .matter_test_config .endpoint == 0 :
220
+ asserts .fail ("Expected failure" )
221
+
222
+ @per_endpoint_test (has_cluster (Clusters .OnOff ))
223
+ async def test_fail_on_ep1 (self ):
224
+ if self .matter_test_config .endpoint == 1 :
225
+ asserts .fail ("Expected failure" )
226
+
227
+ @per_node_test
228
+ async def test_fail_on_whole_node (self ):
229
+ asserts .fail ("Expected failure" )
214
230
215
231
216
232
def main ():
@@ -279,6 +295,34 @@ def check_skipped(test_name: str):
279
295
check_once_per_endpoint ('test_endpoint_boolean_yes' )
280
296
check_skipped ('test_endpoint_boolean_no' )
281
297
298
+ test_name = 'test_fail_on_ep0'
299
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , test_name )
300
+ read_resp = get_clusters ([0 , 1 ])
301
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
302
+ if ok :
303
+ failures .append (f"Did not get expected test assertion on { test_name } " )
304
+
305
+ test_name = 'test_fail_on_ep1'
306
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , test_name )
307
+ read_resp = get_clusters ([0 , 1 ])
308
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
309
+ if ok :
310
+ failures .append (f"Did not get expected test assertion on { test_name } " )
311
+
312
+ test_name = 'test_fail_on_ep1'
313
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , test_name )
314
+ read_resp = get_clusters ([0 ])
315
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
316
+ if not ok :
317
+ failures .append (f"Unexpected failure on { test_name } " )
318
+
319
+ test_name = 'test_fail_on_whole_node'
320
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , test_name )
321
+ read_resp = get_clusters ([0 , 1 ])
322
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
323
+ if ok :
324
+ failures .append (f"Did not get expected test assertion on { test_name } " )
325
+
282
326
test_runner .Shutdown ()
283
327
print (
284
328
f"Test of Decorators: test response incorrect: { len (failures )} " )
0 commit comments