@@ -58,8 +58,8 @@ def test_list_mbeds_valid_platform(self):
58
58
'serial_port' : 'not_valid' }]
59
59
with patch ("mbed_lstools.lstools_base.MbedLsToolsBase._read_htm_ids" ) as _read_htm ,\
60
60
patch ("mbed_lstools.lstools_base.MbedLsToolsBase.mount_point_ready" ) as _mpr ,\
61
- patch ("mbed_lstools.lstools_base .PlatformDatabase.get" ) as _get ,\
62
- patch ('os. listdir' ) as _listdir :
61
+ patch ("mbed_os_tools.detect.platform_database .PlatformDatabase.get" ) as _get ,\
62
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
63
63
_mpr .return_value = True
64
64
_read_htm .return_value = (u'0241BEEFDEAD' , {})
65
65
_get .return_value = {
@@ -82,8 +82,8 @@ def test_list_mbeds_invalid_tid(self):
82
82
'serial_port' : 'not_valid' }]
83
83
with patch ("mbed_lstools.lstools_base.MbedLsToolsBase._read_htm_ids" ) as _read_htm ,\
84
84
patch ("mbed_lstools.lstools_base.MbedLsToolsBase.mount_point_ready" ) as _mpr ,\
85
- patch ("mbed_lstools.lstools_base .PlatformDatabase.get" ) as _get ,\
86
- patch ('os. listdir' ) as _listdir :
85
+ patch ("mbed_os_tools.detect.platform_database .PlatformDatabase.get" ) as _get ,\
86
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
87
87
_mpr .return_value = True
88
88
_read_htm .side_effect = [(u'0241BEEFDEAD' , {}), (None , {})]
89
89
_get .return_value = {
@@ -103,10 +103,10 @@ def test_list_mbeds_invalid_platform(self):
103
103
'target_id_usb_id' : u'not_in_target_db' ,
104
104
'serial_port' : "dummy_serial_port" }]
105
105
for qos in [FSInteraction .BeforeFilter , FSInteraction .AfterFilter ]:
106
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
107
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
108
- patch ("mbed_lstools.lstools_base .PlatformDatabase.get" ) as _get ,\
109
- patch ('os. listdir' ) as _listdir :
106
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
107
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
108
+ patch ("mbed_os_tools.detect.platform_database .PlatformDatabase.get" ) as _get ,\
109
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
110
110
_mpr .return_value = True
111
111
_read_htm .return_value = (u'not_in_target_db' , {})
112
112
_get .return_value = None
@@ -122,8 +122,8 @@ def test_list_mbeds_unmount_mid_read(self):
122
122
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
123
123
'target_id_usb_id' : u'0240DEADBEEF' ,
124
124
'serial_port' : "dummy_serial_port" }]
125
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
126
- patch ('os. listdir' ) as _listdir :
125
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
126
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
127
127
_mpr .return_value = True
128
128
_listdir .side_effect = OSError
129
129
to_check = self .base .list_mbeds ()
@@ -134,9 +134,9 @@ def _test(mock):
134
134
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
135
135
'target_id_usb_id' : u'0240DEADBEEF' ,
136
136
'serial_port' : "dummy_serial_port" }]
137
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
138
- patch ('os. listdir' ) as _listdir ,\
139
- patch ('mbed_lstools .lstools_base.open' , mock , create = True ):
137
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
138
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir ,\
139
+ patch ('mbed_os_tools.detect .lstools_base.open' , mock , create = True ):
140
140
_mpr .return_value = True
141
141
_listdir .return_value = ['MBED.HTM' , 'DETAILS.TXT' ]
142
142
to_check = self .base .list_mbeds ()
@@ -180,9 +180,9 @@ def _handle_open(*args, **kwargs):
180
180
return DEFAULT
181
181
182
182
m = mock_open (read_data = details_txt_contents )
183
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
184
- patch ('os. listdir' ) as _listdir ,\
185
- patch ('mbed_lstools .lstools_base.open' , m , create = True ) as mocked_open :
183
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
184
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir ,\
185
+ patch ('mbed_os_tools.detect .lstools_base.open' , m , create = True ) as mocked_open :
186
186
mocked_open .side_effect = _handle_open
187
187
_mpr .return_value = True
188
188
_listdir .return_value = ['PRODINFO.HTM' , 'DETAILS.TXT' ]
@@ -196,10 +196,10 @@ def _test(mock):
196
196
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
197
197
'target_id_usb_id' : u'0240DEADBEEF' ,
198
198
'serial_port' : "dummy_serial_port" }]
199
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
200
- patch ('os. listdir' ) as _listdir ,\
201
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._update_device_from_htm" ) as _htm ,\
202
- patch ('mbed_lstools .lstools_base.open' , mock , create = True ):
199
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
200
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir ,\
201
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._update_device_from_htm" ) as _htm ,\
202
+ patch ('mbed_os_tools.detect .lstools_base.open' , mock , create = True ):
203
203
_mpr .return_value = True
204
204
_htm .side_effect = None
205
205
_listdir .return_value = ['MBED.HTM' , 'DETAILS.TXT' ]
@@ -220,8 +220,8 @@ def test_list_mbeds_unmount_mid_read_list_unmounted(self):
220
220
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
221
221
'target_id_usb_id' : u'0240DEADBEEF' ,
222
222
'serial_port' : "dummy_serial_port" }]
223
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
224
- patch ('os. listdir' ) as _listdir :
223
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
224
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
225
225
_mpr .return_value = True
226
226
_listdir .side_effect = OSError
227
227
to_check = self .base .list_mbeds ()
@@ -277,7 +277,7 @@ def test_update_device_from_fs_mid_unmount(self):
277
277
'mount_point' : dummy_mount
278
278
}
279
279
280
- with patch ('os. listdir' ) as _listdir :
280
+ with patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
281
281
_listdir .side_effect = OSError
282
282
self .base ._update_device_from_fs (device , False )
283
283
self .assertEqual (device ['mount_point' ], None )
@@ -305,8 +305,8 @@ def test_device_type_unmounted(self):
305
305
'serial_port' : "dummy_serial_port" ,
306
306
'vendor_id' : '0d28' ,
307
307
'product_id' : '0204' }]
308
- with patch ("mbed_lstools.lstools_base .PlatformDatabase.get" ) as _get ,\
309
- patch ('os. listdir' ) as _listdir :
308
+ with patch ("mbed_os_tools.detect.platform_database .PlatformDatabase.get" ) as _get ,\
309
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
310
310
_get .return_value = {
311
311
'platform_name' : 'foo_target'
312
312
}
@@ -327,7 +327,7 @@ def test_update_device_details_jlink(self):
327
327
'mount_point' : dummy_mount_point
328
328
}
329
329
330
- with patch ('mbed_lstools .lstools_base.open' , _open , create = True ):
330
+ with patch ('mbed_os_tools.detect .lstools_base.open' , _open , create = True ):
331
331
device = deepcopy (base_device )
332
332
device ['directory_entries' ] = ['Board.html' , 'User Guide.html' ]
333
333
self .base ._update_device_details_jlink (device , False )
@@ -358,8 +358,8 @@ def test_fs_never(self):
358
358
'serial_port' : 'invalid_serial_port'
359
359
}
360
360
self .base .return_value = [device ]
361
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._update_device_from_fs" ) as _up_fs ,\
362
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready :
361
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._update_device_from_fs" ) as _up_fs ,\
362
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready :
363
363
mount_point_ready .return_value = True
364
364
365
365
filter = None
@@ -396,10 +396,10 @@ def test_fs_after(self):
396
396
'mount_point' : 'invalid_mount_point' ,
397
397
'serial_port' : 'invalid_serial_port'
398
398
}
399
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
400
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._details_txt" ) as _up_details ,\
401
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
402
- patch ('os. listdir' ) as _listdir :
399
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
400
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._details_txt" ) as _up_details ,\
401
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
402
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
403
403
new_device_id = "00017531642046"
404
404
_read_htm .return_value = (new_device_id , {})
405
405
_listdir .return_value = ['mbed.htm' , 'details.txt' ]
@@ -470,10 +470,10 @@ def test_fs_before(self):
470
470
'mount_point' : 'invalid_mount_point' ,
471
471
'serial_port' : 'invalid_serial_port'
472
472
}
473
- with patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
474
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase ._details_txt" ) as _up_details ,\
475
- patch ("mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
476
- patch ('os. listdir' ) as _listdir :
473
+ with patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
474
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase ._details_txt" ) as _up_details ,\
475
+ patch ("mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
476
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
477
477
new_device_id = u'00017575430420'
478
478
_read_htm .return_value = (new_device_id , {})
479
479
_listdir .return_value = ['mbed.htm' , 'details.txt' ]
@@ -552,7 +552,9 @@ def setUp(self):
552
552
_open = mock_open (read_data = json .dumps (retarget_data ))
553
553
554
554
with patch ('os.path.isfile' ) as _isfile ,\
555
- patch ('mbed_lstools.lstools_base.open' , _open , create = True ):
555
+ patch ('mbed_os_tools.detect.lstools_base.isfile' ) as _isfile ,\
556
+ patch ('mbed_os_tools.detect.lstools_base.open' , _open , create = True ):
557
+ _isfile .return_value = True
556
558
self .base = DummyLsTools ()
557
559
_open .assert_called ()
558
560
@@ -563,10 +565,10 @@ def test_list_mbeds_valid_platform(self):
563
565
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
564
566
'target_id_usb_id' : u'0240DEADBEEF' ,
565
567
'serial_port' : None }]
566
- with patch ('mbed_lstools.lstools_base.MbedLsToolsBase ._read_htm_ids' ) as _read_htm ,\
567
- patch ('mbed_lstools.lstools_base.MbedLsToolsBase .mount_point_ready' ) as _mpr ,\
568
- patch ('mbed_lstools.lstools_base .PlatformDatabase.get' ) as _get ,\
569
- patch ('os. listdir' ) as _listdir :
568
+ with patch ('mbed_lstools.lstools_base.MbedDetectLsToolsBase ._read_htm_ids' ) as _read_htm ,\
569
+ patch ('mbed_lstools.lstools_base.MbedDetectLsToolsBase .mount_point_ready' ) as _mpr ,\
570
+ patch ('mbed_os_tools.detect.platform_database .PlatformDatabase.get' ) as _get ,\
571
+ patch ("mbed_os_tools.detect.lstools_base. listdir" ) as _listdir :
570
572
_mpr .return_value = True
571
573
_read_htm .return_value = (u'0240DEADBEEF' , {})
572
574
_get .return_value = {
0 commit comments