def test_multi_checker(self): checker = retryhandler.ServiceErrorCodeChecker( status_code=400, error_code='Throttled') checker2 = retryhandler.HTTPStatusCodeChecker(500) self.checker = retryhandler.MultiChecker([checker, checker2]) self.assert_should_be_retried((HTTP_500_RESPONSE, {})) self.assert_should_be_retried( response=(HTTP_400_RESPONSE, {'Errors': [{'Code': 'Throttled'}]})) self.assert_should_not_be_retried( response=(HTTP_200_RESPONSE, {}))
def test_error_code_checker_ignore_caught_exception(self): self.checker = retryhandler.ServiceErrorCodeChecker( status_code=400, error_code='Throttled') self.assert_should_not_be_retried(response=None, caught_exception=RuntimeError())
def test_error_code_checker_does_not_match(self): self.checker = retryhandler.ServiceErrorCodeChecker( status_code=400, error_code='Throttled') response = (HTTP_400_RESPONSE, {'Errors': [{'Code': 'NotThrottled'}]}) self.assert_should_not_be_retried(response)
def test_error_code_checker(self): self.checker = retryhandler.ServiceErrorCodeChecker( status_code=400, error_code='Throttled') response = (HTTP_400_RESPONSE, {'Error': {'Code': 'Throttled'}}) self.assert_should_be_retried(response)