def test_with_message(self): """Testing WebAPIError.with_message""" orig_msg = 'Original message' new_msg = 'New message' headers = { 'foo': 'bar', } orig_error = WebAPIError(123, orig_msg, http_status=500, headers=headers) new_error = orig_error.with_message(new_msg) self.assertNotEqual(orig_error, new_error) self.assertEqual(new_error.msg, new_msg) self.assertEqual(new_error.headers, headers) self.assertEqual(new_error.code, orig_error.code) self.assertEqual(new_error.http_status, orig_error.http_status) self.assertEqual(orig_error.msg, orig_msg) self.assertEqual(orig_error.headers, headers)
from djblets.webapi.errors import WebAPIError # # Standard error messages # UNSPECIFIED_DIFF_REVISION = WebAPIError(200, "Diff revision not specified", http_status=400) # 400 Bad Request) INVALID_DIFF_REVISION = WebAPIError(201, "Invalid diff revision", http_status=404) # 404 Not Found INVALID_ACTION = WebAPIError(202, "Invalid action specified", http_status=400) # 400 Bad Request INVALID_CHANGE_NUMBER = WebAPIError(203, "The change number specified " "could not be found", http_status=404) # 404 Not Found CHANGE_NUMBER_IN_USE = WebAPIError(204, "The change number specified " "has already been used", http_status=409) # 409 Conflict MISSING_REPOSITORY = WebAPIError(205, "There was no repository found " "at the specified path", http_status=400) # 400 Bad Request INVALID_REPOSITORY = WebAPIError(206, "The repository path specified " "is not in the list of known " "repositories", http_status=400) # 400 Bad Request REPO_FILE_NOT_FOUND = WebAPIError(207, "The file was not found in the " "repository", http_status=400) # 400 Bad Request INVALID_USER = WebAPIError(208, "User does not exist", http_status=400) # 400 Bad Request REPO_NOT_IMPLEMENTED = WebAPIError(209, "The specified repository is "
from __future__ import unicode_literals from djblets.webapi.errors import WebAPIError class WebAPITokenGenerationError(Exception): """An error generating a Web API token.""" pass # # Standard error messages # UNSPECIFIED_DIFF_REVISION = WebAPIError(200, "Diff revision not specified.", http_status=400) # 400 Bad Request INVALID_DIFF_REVISION = WebAPIError(201, "Invalid diff revision.", http_status=404) # 404 Not Found INVALID_ACTION = WebAPIError(202, "Invalid action specified.", http_status=400) # 400 Bad Request INVALID_CHANGE_NUMBER = WebAPIError( 203, "The change number specified could not be found.", http_status=404) # 404 Not Found CHANGE_NUMBER_IN_USE = WebAPIError( 204, "The change number specified has already been used.", http_status=409) # 409 Conflict
class BugzillaUserMapError(Exception): "Non existing Bugzilla user is mapped to MozReview user." class ReviewerUserMapError(PublishError): def __init__(self, username): PublishError.__init__(self, 'Chosen reviewer (%s) is assigned to a ' 'non-existing Bugzilla user. If you believe you ' 'received this message in error, please ask for ' 'help on IRC#mozreview.' % username) NOT_PARENT = WebAPIError( 1001, "Review request is not a parent", http_status=400) # 400 Bad Request CHILD_DOES_NOT_EXIST = WebAPIError( 1002, "Child review request does not exist", http_status=500) # 500 Internal Server Error class WebLoginNeededError(Exception): """Raised when a request requires the user to log in via the web site.""" class BugzillaAPIKeyNeededError(Exception): """User should visit Bugzilla to obtain an API key.""" def __init__(self, url):