Exemple #1
0
 def test_messages(self):
     assert 'Unhandled HTTP error' in str(exceptions.HttpError())
     assert 'Bad request' in str(exceptions.BadRequest())
     assert 'Unauthorized. Please check your secret key' in str(
         exceptions.Unauthorized())
     assert 'Forbidden error. You are not allowed to access this resource' in str(
         exceptions.Forbidden())
     assert 'The resource you requested could not be found' in str(
         exceptions.NotFound())
     assert 'The requested method is not supported by this resource' in str(
         exceptions.NotAllowed())
     assert 'Unexpected server error during the request' in str(
         exceptions.PayPlugServerError())
     assert 'API response is not valid JSON' in str(
         exceptions.UnexpectedAPIResponseException())
Exemple #2
0
 def test_response_included_in_message(self):
     assert ('The server gave the following response: `"a response"`.'
             in str(exceptions.HttpError(http_response='"a response"')))
Exemple #3
0
 def test_get_error_object_invalid_json(self):
     http_error = exceptions.HttpError(
         http_status=500, http_response='["invalid", "json", "response"')
     assert http_error.error_object is None
Exemple #4
0
 def test_get_response_code(self):
     http_error = exceptions.HttpError(http_status=500, http_response=None)
     assert http_error.http_response_code == 500
Exemple #5
0
 def test_get_error_object_valid_json(self):
     http_error = exceptions.HttpError(
         http_status=500, http_response='["valid", "json", "response"]')
     assert http_error.error_object == ['valid', 'json', 'response']