def test_get_device_too_many_matches(self): ads = get_mock_ads(5) target_serial = ads[1].serial = ads[0].serial expected_msg = "More than one device matched: \[0, 0\]" with self.assertRaisesRegex(android_device.AndroidDeviceError, expected_msg): ad = android_device.get_device(ads, serial=target_serial)
def test_get_device_no_match(self): ads = get_mock_ads(5) expected_msg = ("Could not find a target device that matches condition" ": {'serial': 5}.") with self.assertRaisesRegex(android_device.AndroidDeviceError, expected_msg): ad = android_device.get_device(ads, serial=len(ads))
def test_get_device_success_with_serial_and_extra_field(self): ads = get_mock_ads(5) expected_serial = 1 expected_h_port = 5555 ads[1].h_port = expected_h_port ad = android_device.get_device(ads, serial=expected_serial, h_port=expected_h_port) self.assertEqual(ad.serial, expected_serial) self.assertEqual(ad.h_port, expected_h_port)
def test_get_device_success_with_serial(self): ads = get_mock_ads(5) expected_serial = 0 ad = android_device.get_device(ads, serial=expected_serial) self.assertEqual(ad.serial, expected_serial)