Skip to content

Commit efbbcca

Browse files
committed
Fixing up tests for new device type detection location
1 parent 91d2f24 commit efbbcca

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

test/mbedls_toolsbase.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,8 @@ def test_update_device_from_fs_mid_unmount(self):
280280
with patch('os.listdir') as _listdir:
281281
_listdir.side_effect = OSError
282282
self.base._update_device_from_fs(device, False)
283-
self.assertEqual(device['device_type'], 'unknown')
284283
self.assertEqual(device['mount_point'], None)
285284

286-
def test_update_device_from_fs_unknown(self):
287-
device = {}
288-
self.base._update_device_from_fs(device, False)
289-
self.assertEqual(device['device_type'], 'unknown')
290-
291285
def test_detect_device_test(self):
292286
device_type = self.base._detect_device_type({
293287
'vendor_id': '0483'
@@ -304,6 +298,25 @@ def test_detect_device_test(self):
304298
})
305299
self.assertEqual(device_type, 'jlink')
306300

301+
def test_device_type_unmounted(self):
302+
self.base.list_unmounted = True
303+
self.base.return_value = [{'mount_point': None,
304+
'target_id_usb_id': u'0240DEADBEEF',
305+
'serial_port': "dummy_serial_port",
306+
'vendor_id': '0d28',
307+
'product_id': '0204'}]
308+
with patch("mbed_lstools.lstools_base.PlatformDatabase.get") as _get,\
309+
patch('os.listdir') as _listdir:
310+
_get.return_value = {
311+
'platform_name': 'foo_target'
312+
}
313+
to_check = self.base.list_mbeds()
314+
#_get.assert_any_call('0240', device_type='daplink', verbose_data=True)
315+
self.assertEqual(len(to_check), 1)
316+
self.assertEqual(to_check[0]['target_id'], "0240DEADBEEF")
317+
self.assertEqual(to_check[0]['platform_name'], 'foo_target')
318+
self.assertEqual(to_check[0]['device_type'], 'daplink')
319+
307320
def test_update_device_details_jlink(self):
308321
jlink_html_contents = ('<html><head><meta http-equiv="refresh" '
309322
'content="0; url=http://www.nxp.com/FRDM-KL27Z"/>'

0 commit comments

Comments
 (0)