@@ -351,6 +351,7 @@ def test_fs_before(self):
351
351
'mount_point' : 'invalid_mount_point' ,
352
352
'serial_port' : 'invalid_serial_port'
353
353
}
354
+ self .base .list_unmounted = True
354
355
with patch ("mbed_lstools.lstools_base.MbedLsToolsBase._read_htm_ids" ) as _read_htm ,\
355
356
patch ("mbed_lstools.lstools_base.MbedLsToolsBase._details_txt" ) as _up_details ,\
356
357
patch ('os.listdir' ) as _listdir :
@@ -362,15 +363,19 @@ def test_fs_before(self):
362
363
}
363
364
364
365
filter = None
365
- ret = self .base ._fs_before_id_check (deepcopy (device ), filter , False )
366
+ self .base .return_value = [deepcopy (device )]
367
+ ret = self .base .list_mbeds (
368
+ FSInteraction .BeforeFilter , filter , False , False )
366
369
_up_details .assert_not_called ()
367
370
368
- ret_with_details = self .base ._fs_before_id_check (deepcopy (device ), filter , True )
369
- self .assertIsNotNone (ret )
370
- self .assertIsNotNone (ret_with_details )
371
- self .assertEqual (ret ['target_id' ], new_device_id )
372
- self .assertEqual (ret_with_details ['daplink_automation_allowed' ], '0' )
373
- self .assertDictContainsSubset (ret , ret_with_details )
371
+ self .base .return_value = [deepcopy (device )]
372
+ ret_with_details = self .base .list_mbeds (
373
+ FSInteraction .BeforeFilter , filter , False , True )
374
+ self .assertIsNotNone (ret [0 ])
375
+ self .assertIsNotNone (ret_with_details [0 ])
376
+ self .assertEqual (ret [0 ]['target_id' ], new_device_id )
377
+ self .assertEqual (ret_with_details [0 ]['daplink_automation_allowed' ], '0' )
378
+ self .assertDictContainsSubset (ret [0 ], ret_with_details [0 ])
374
379
_read_htm .assert_called_with (device ['mount_point' ])
375
380
_up_details .assert_called_with (device ['mount_point' ])
376
381
@@ -379,17 +384,20 @@ def test_fs_before(self):
379
384
380
385
filter_in = lambda m : m ['target_id' ] == '00017575430420'
381
386
filter_in_details = lambda m : m ['daplink_automation_allowed' ] == '0'
382
- ret = self .base ._fs_before_id_check (deepcopy (device ), filter_in , False )
387
+ self .base .return_value = [deepcopy (device )]
388
+ ret = self .base .list_mbeds (
389
+ FSInteraction .BeforeFilter , filter_in , False , False )
383
390
_up_details .assert_not_called ()
384
391
385
- ret_with_details = self .base ._fs_before_id_check (deepcopy (device ),
386
- filter_in_details ,
387
- True )
388
- self .assertIsNotNone (ret )
389
- self .assertIsNotNone (ret_with_details )
390
- self .assertEqual (ret ['target_id' ], new_device_id )
391
- self .assertEqual (ret_with_details ['daplink_automation_allowed' ], '0' )
392
- self .assertDictContainsSubset (ret , ret_with_details )
392
+ self .base .return_value = [deepcopy (device )]
393
+ ret_with_details = self .base .list_mbeds (
394
+ FSInteraction .BeforeFilter , filter_in_details , False , True )
395
+
396
+ self .assertIsNotNone (ret [0 ])
397
+ self .assertIsNotNone (ret_with_details [0 ])
398
+ self .assertEqual (ret [0 ]['target_id' ], new_device_id )
399
+ self .assertEqual (ret_with_details [0 ]['daplink_automation_allowed' ], '0' )
400
+ self .assertDictContainsSubset (ret [0 ], ret_with_details [0 ])
393
401
_read_htm .assert_called_with (device ['mount_point' ])
394
402
_up_details .assert_called_with (device ['mount_point' ])
395
403
@@ -398,14 +406,16 @@ def test_fs_before(self):
398
406
399
407
filter_out = lambda m : m ['target_id' ] == '024075309420ABCE'
400
408
filter_out_details = lambda m : m ['daplink_automation_allowed' ] == '1'
401
- ret = self .base ._fs_before_id_check (deepcopy (device ), filter_out , False )
409
+ ret = self .base .list_mbeds (
410
+ FSInteraction .BeforeFilter , filter_out , False , False )
402
411
_up_details .assert_not_called ()
403
412
404
- ret_with_details = self .base ._fs_before_id_check (deepcopy (device ),
405
- filter_out_details ,
406
- True )
407
- self .assertIsNone (ret )
408
- self .assertIsNone (ret_with_details )
413
+ self .base .return_value = [deepcopy (device )]
414
+ ret_with_details = self .base .list_mbeds (
415
+ FSInteraction .BeforeFilter , filter_out_details , False , True )
416
+
417
+ self .assertEqual (ret , [])
418
+ self .assertEqual (ret_with_details , [])
409
419
_read_htm .assert_called_with (device ['mount_point' ])
410
420
411
421
class RetargetTestCase (unittest .TestCase ):
0 commit comments