Beispiel #1
0
 def test_update_data_eventually_fails(self, _log):
     client = mock.Mock()
     client.get.return_value = None
     client.put.side_effect = cloud_exceptions.ServiceUnavailable(
         'permanent failure')
     status = scraper.SyncStatus(client, None)
     with self.assertRaises(cloud_exceptions.ServiceUnavailable):
         status.update_data('key', 'value')
Beispiel #2
0
 def test_get_data_fails_eventually(self, _log):
     client = mock.Mock()
     client.key.return_value = {}
     client.get.side_effect = cloud_exceptions.ServiceUnavailable(
         'permanent failure')
     status = scraper.SyncStatus(client, None)
     with self.assertRaises(cloud_exceptions.ServiceUnavailable):
         status.get_data()
Beispiel #3
0
 def test_update_data_robustness(self, _log):
     client = mock.Mock()
     client.get.return_value = None
     client.put.side_effect = [
         cloud_exceptions.ServiceUnavailable('one failure'), None
     ]
     status = scraper.SyncStatus(client, None)
     status.update_data('key', 'value')
Beispiel #4
0
 def test_get_data_robustness(self, _log):
     client = mock.Mock()
     client.key.return_value = {}
     client.get.side_effect = [
         cloud_exceptions.ServiceUnavailable('one failure'), {}
     ]
     status = scraper.SyncStatus(client, None)
     status.get_data()
 def test_create_bucket_api_call_retry(self, mock_write_spinner_and_log,
                                       mock_bucket):
     """Tests the method is retried 5 times when the exception happens."""
     mock_bucket.create.side_effect = exceptions.ServiceUnavailable('503')
     with self.assertRaises(RetryError):
         result = bucket_mover_service._create_bucket_api_call(
             mock.MagicMock(), mock.MagicMock(), mock_bucket)
         self.assertEqual(5, mock_bucket.create.call_count)
         self.assertEqual(5, mock_write_spinner_and_log.call_count)
         self.assertFalse(result)