24
24
from mock import patch , mock_open , DEFAULT
25
25
from copy import deepcopy
26
26
27
- from mbed_os_tools .detect .lstools_base import MbedDetectLsToolsBase , FSInteraction
27
+ from mbed_os_tools .detect .lstools_base import MbedLsToolsBase , FSInteraction
28
28
29
- class DummyLsTools (MbedDetectLsToolsBase ):
29
+ class DummyLsTools (MbedLsToolsBase ):
30
30
return_value = []
31
31
def find_candidates (self ):
32
32
return self .return_value
@@ -54,8 +54,8 @@ def test_list_mbeds_valid_platform(self):
54
54
{'mount_point' : None ,
55
55
'target_id_usb_id' : '00000000000' ,
56
56
'serial_port' : 'not_valid' }]
57
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
58
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
57
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
58
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
59
59
patch ("mbed_os_tools.detect.lstools_base.PlatformDatabase.get" ) as _get ,\
60
60
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
61
61
_mpr .return_value = True
@@ -78,8 +78,8 @@ def test_list_mbeds_invalid_tid(self):
78
78
{'mount_point' : 'dummy_mount_point' ,
79
79
'target_id_usb_id' : "" ,
80
80
'serial_port' : 'not_valid' }]
81
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
82
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
81
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
82
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
83
83
patch ("mbed_os_tools.detect.lstools_base.PlatformDatabase.get" ) as _get ,\
84
84
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
85
85
_mpr .return_value = True
@@ -101,8 +101,8 @@ def test_list_mbeds_invalid_platform(self):
101
101
'target_id_usb_id' : u'not_in_target_db' ,
102
102
'serial_port' : "dummy_serial_port" }]
103
103
for qos in [FSInteraction .BeforeFilter , FSInteraction .AfterFilter ]:
104
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
105
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
104
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
105
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
106
106
patch ("mbed_os_tools.detect.lstools_base.PlatformDatabase.get" ) as _get ,\
107
107
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
108
108
_mpr .return_value = True
@@ -120,7 +120,7 @@ def test_list_mbeds_unmount_mid_read(self):
120
120
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
121
121
'target_id_usb_id' : u'0240DEADBEEF' ,
122
122
'serial_port' : "dummy_serial_port" }]
123
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
123
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
124
124
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
125
125
_mpr .return_value = True
126
126
_listdir .side_effect = OSError
@@ -132,7 +132,7 @@ def _test(mock):
132
132
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
133
133
'target_id_usb_id' : u'0240DEADBEEF' ,
134
134
'serial_port' : "dummy_serial_port" }]
135
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
135
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
136
136
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir ,\
137
137
patch ('mbed_os_tools.detect.lstools_base.open' , mock , create = True ):
138
138
_mpr .return_value = True
@@ -178,7 +178,7 @@ def _handle_open(*args, **kwargs):
178
178
return DEFAULT
179
179
180
180
m = mock_open (read_data = details_txt_contents )
181
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
181
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
182
182
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir ,\
183
183
patch ('mbed_os_tools.detect.lstools_base.open' , m , create = True ) as mocked_open :
184
184
mocked_open .side_effect = _handle_open
@@ -194,9 +194,9 @@ def _test(mock):
194
194
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
195
195
'target_id_usb_id' : u'0240DEADBEEF' ,
196
196
'serial_port' : "dummy_serial_port" }]
197
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
197
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
198
198
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir ,\
199
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._update_device_from_htm" ) as _htm ,\
199
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._update_device_from_htm" ) as _htm ,\
200
200
patch ('mbed_os_tools.detect.lstools_base.open' , mock , create = True ):
201
201
_mpr .return_value = True
202
202
_htm .side_effect = None
@@ -218,7 +218,7 @@ def test_list_mbeds_unmount_mid_read_list_unmounted(self):
218
218
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
219
219
'target_id_usb_id' : u'0240DEADBEEF' ,
220
220
'serial_port' : "dummy_serial_port" }]
221
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as _mpr ,\
221
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as _mpr ,\
222
222
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
223
223
_mpr .return_value = True
224
224
_listdir .side_effect = OSError
@@ -352,8 +352,8 @@ def test_fs_never(self):
352
352
'serial_port' : 'invalid_serial_port'
353
353
}
354
354
self .base .return_value = [device ]
355
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._update_device_from_fs" ) as _up_fs ,\
356
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready :
355
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._update_device_from_fs" ) as _up_fs ,\
356
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready :
357
357
mount_point_ready .return_value = True
358
358
359
359
filter = None
@@ -390,9 +390,9 @@ def test_fs_after(self):
390
390
'mount_point' : 'invalid_mount_point' ,
391
391
'serial_port' : 'invalid_serial_port'
392
392
}
393
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
394
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._details_txt" ) as _up_details ,\
395
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
393
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
394
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._details_txt" ) as _up_details ,\
395
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
396
396
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
397
397
new_device_id = "00017531642046"
398
398
_read_htm .return_value = (new_device_id , {})
@@ -464,9 +464,9 @@ def test_fs_before(self):
464
464
'mount_point' : 'invalid_mount_point' ,
465
465
'serial_port' : 'invalid_serial_port'
466
466
}
467
- with patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids" ) as _read_htm ,\
468
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._details_txt" ) as _up_details ,\
469
- patch ("mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
467
+ with patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids" ) as _read_htm ,\
468
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._details_txt" ) as _up_details ,\
469
+ patch ("mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready" ) as mount_point_ready ,\
470
470
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
471
471
new_device_id = u'00017575430420'
472
472
_read_htm .return_value = (new_device_id , {})
@@ -557,8 +557,8 @@ def test_list_mbeds_valid_platform(self):
557
557
self .base .return_value = [{'mount_point' : 'dummy_mount_point' ,
558
558
'target_id_usb_id' : u'0240DEADBEEF' ,
559
559
'serial_port' : None }]
560
- with patch ('mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase ._read_htm_ids' ) as _read_htm ,\
561
- patch ('mbed_os_tools.detect.lstools_base.MbedDetectLsToolsBase .mount_point_ready' ) as _mpr ,\
560
+ with patch ('mbed_os_tools.detect.lstools_base.MbedLsToolsBase ._read_htm_ids' ) as _read_htm ,\
561
+ patch ('mbed_os_tools.detect.lstools_base.MbedLsToolsBase .mount_point_ready' ) as _mpr ,\
562
562
patch ('mbed_os_tools.detect.lstools_base.PlatformDatabase.get' ) as _get ,\
563
563
patch ('mbed_os_tools.detect.lstools_base.listdir' ) as _listdir :
564
564
_mpr .return_value = True
0 commit comments