Esempio n. 1
0
 def test_retry_on_exception_five_attempts(self):
     success_on_fifth_attempt = raise_until_attempt(
         5, exceptions.RequestBad(uri='', response=''))
     should_return_five = vcns.retry_upon_exception(
         exceptions.RequestBad,
         max_attempts=10)(success_on_fifth_attempt)
     self.assertEqual(5, should_return_five())
Esempio n. 2
0
 def test_retry_on_exception_exceed_attempts(self):
     success_on_fifth_attempt = raise_until_attempt(
         5, exceptions.RequestBad(uri='', response=''))
     should_raise = vcns.retry_upon_exception(
         exceptions.RequestBad,
         max_attempts=4)(success_on_fifth_attempt)
     self.assertRaises(exceptions.RequestBad, should_raise)
Esempio n. 3
0
 def test_retry_on_exception_one_attempt(self):
     success_on_first_attempt = raise_until_attempt(
         1, exceptions.RequestBad(uri='', response=''))
     should_return_one = vcns.retry_upon_exception(
         exceptions.RequestBad,
         max_attempts=1)(success_on_first_attempt)
     self.assertEqual(1, should_return_one())
Esempio n. 4
0
 def test_retry_on_exception_exclude_error_codes_raise(self):
     success_on_fifth_attempt = raise_until_attempt(
         5, exceptions.RequestBad(uri='', response=self.response))
     # excluding the returned error code, so no retries are expected
     should_raise = vcns.retry_upon_exception_exclude_error_codes(
         exceptions.RequestBad, [1],
         max_attempts=10)(success_on_fifth_attempt)
     self.assertRaises(exceptions.RequestBad, should_raise)
Esempio n. 5
0
 def test_retry_on_exception_exclude_error_codes_retry(self):
     success_on_fifth_attempt = raise_until_attempt(
         5, exceptions.RequestBad(uri='', response=self.response))
     # excluding another error code, so should retry
     should_return_five = vcns.retry_upon_exception_exclude_error_codes(
         exceptions.RequestBad, [2],
         max_attempts=10)(success_on_fifth_attempt)
     self.assertEqual(5, should_return_five())