def test_start_services_on_ads(self): """Makes sure when an AndroidDevice fails to start some services, all AndroidDevice objects get cleaned up. """ msg = 'Some error happened.' ads = mock_android_device.get_mock_ads(3) ads[0].services.register = mock.MagicMock() ads[0].services.stop_all = mock.MagicMock() ads[1].services.register = mock.MagicMock() ads[1].services.stop_all = mock.MagicMock() ads[2].services.register = mock.MagicMock( side_effect=android_device.Error(msg)) ads[2].services.stop_all = mock.MagicMock() with self.assertRaisesRegex(android_device.Error, msg): android_device._start_services_on_ads(ads) ads[0].services.stop_all.assert_called_once_with() ads[1].services.stop_all.assert_called_once_with() ads[2].services.stop_all.assert_called_once_with()
def test_start_services_on_ads(self): """Makes sure when an AndroidDevice fails to start some services, all AndroidDevice objects get cleaned up. """ msg = 'Some error happened.' ads = mock_android_device.get_mock_ads(3) for ad in ads: ad.services.logcat.start = mock.MagicMock() ad.services.stop_all = mock.MagicMock() ad.skip_logcat = False ad.is_required = True ads[1].services.logcat.start = mock.MagicMock( side_effect=android_device.Error(msg)) with self.assertRaisesRegex(android_device.Error, msg): android_device._start_services_on_ads(ads) ads[0].services.stop_all.assert_called_once_with() ads[1].services.stop_all.assert_called_once_with() ads[2].services.stop_all.assert_called_once_with()