def test_handles_non_error_top_level_error_key_get_error_code(self): response = AWSResponse( status_code=200, raw=None, headers={}, url='https://foo', ) # A normal response can have a top level "Error" key that doesn't map # to an error code and should be ignored context = standard.RetryContext( attempt_number=1, operation_model=None, parsed_response={'Error': 'This is a 200 response body'}, http_response=response, caught_exception=None, ) self.assertEqual(context.get_error_code(), None)
def test_not_idp_communication_error(self): context = standard.RetryContext( attempt_number=1, operation_model=create_fake_op_model('sts'), parsed_response={ 'Error': { 'Code': 'NotIDPCommunicationError', 'Message': 'message' } }, http_response=AWSResponse(status_code=400, raw=None, headers={}, url='https://foo'), caught_exception=None, ) self.assertFalse(self.checker.is_retryable(context))
def _verify_retryable(checker, operation_model, status_code, error, is_retryable): http_response = AWSResponse(status_code=status_code, raw=None, headers={}, url='https://foo/') parsed_response = None caught_exception = None if error is not None: if isinstance(error, Exception): caught_exception = error else: parsed_response = {'Error': {'Code': error, 'Message': 'Error'}} context = standard.RetryContext( attempt_number=1, operation_model=operation_model, parsed_response=parsed_response, http_response=http_response, caught_exception=caught_exception, ) assert checker.is_retryable(context) == is_retryable