@@ -105,6 +105,10 @@ def show_prompt(self,
105
105
106
106
107
107
class TestDecorators (MatterBaseTest ):
108
+ def teardown_test (self ):
109
+ if 'force_endpoint' in self .user_params .keys ():
110
+ del self .user_params ['force_endpoint' ]
111
+
108
112
def test_checkers (self ):
109
113
has_onoff = has_cluster (Clusters .OnOff )
110
114
has_onoff_onoff = has_attribute (Clusters .OnOff .Attributes .OnOff )
@@ -153,7 +157,31 @@ async def test_endpoints(self):
153
157
endpoints = await get_accepted_endpoints_for_test (self , has_timesync_utc )
154
158
asserts .assert_equal (endpoints , [], msg )
155
159
160
+ @async_test_body
161
+ async def test_force_endpoint_good (self ):
162
+ has_onoff = has_cluster (Clusters .OnOff )
163
+
164
+ all_endpoints = await self .default_controller .Read (self .dut_node_id , [()])
165
+ all_endpoints = list (all_endpoints .attributes .keys ())
166
+
167
+ msg = "Unexpected endpoint list returned"
168
+
169
+ for e in all_endpoints :
170
+ self .user_params ['force_endpoint' ] = e
171
+ endpoints = await get_accepted_endpoints_for_test (self , has_onoff )
172
+ asserts .assert_equal (endpoints , [e ], msg )
173
+
174
+ @async_test_body
175
+ async def test_force_endpoint_bad (self ):
176
+ ''' This test should cause an assertion because the forced endpoint does not match the requirements.'''
177
+ has_onoff = has_cluster (Clusters .OnOff )
178
+ all_endpoints = list (all_endpoints .attributes .keys ())
179
+ forced = max (all_endpoints + 1 )
180
+ self .user_params ['force_endpoint' ] = e
181
+ endpoints = await get_accepted_endpoints_for_test (self , has_onoff )
182
+
156
183
# This test should cause an assertion because it has pics_ method
184
+
157
185
@run_once_for_node
158
186
async def test_whole_node_with_pics (self ):
159
187
pass
@@ -258,6 +286,18 @@ def main():
258
286
if not ok :
259
287
failures .append ("Test case failure: test_endpoints" )
260
288
289
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , 'test_force_endpoint_good' )
290
+ read_resp = get_clusters ([0 , 1 ])
291
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
292
+ if not ok :
293
+ failures .append ("Test case failure: test_force_endpoint_good" )
294
+
295
+ test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , 'test_force_endpoint_bad' )
296
+ read_resp = get_clusters ([0 , 1 ])
297
+ ok = test_runner .run_test_with_mock_read (read_resp , hooks )
298
+ if ok :
299
+ failures .append ("Test case failure: test_force_endpoint_bad" )
300
+
261
301
test_name = 'test_whole_node_with_pics'
262
302
test_runner .set_test ('TestDecorators.py' , 'TestDecorators' , test_name )
263
303
ok = test_runner .run_test_with_mock_read (read_resp , hooks )
0 commit comments