def test_403(self): def raise_exception(*args, **kwargs): from django.core.exceptions import PermissionDenied raise PermissionDenied() wrapper = wrap_exceptions(raise_exception) self.assertXmlrpcFaultForbidden(wrapper)
def test_403(self): def raise_exception(*args, **kwargs): from django.core.exceptions import PermissionDenied raise PermissionDenied() wrapper = wrap_exceptions(raise_exception) self.assertRaisesXmlrpcFault(http_client.FORBIDDEN, wrapper)
def test_409(self): def raise_exception(*args, **kwargs): from django.db.utils import IntegrityError raise IntegrityError() wrapper = wrap_exceptions(raise_exception) self.assertXmlrpcFaultConflict(wrapper)
def test_404(self): def raise_exception(*args, **kwargs): from django.db.models import ObjectDoesNotExist raise ObjectDoesNotExist() wrapper = wrap_exceptions(raise_exception) self.assertXmlrpcFaultNotFound(wrapper)
def test_409(self): def raise_exception(*args, **kwargs): from django.db.utils import IntegrityError raise IntegrityError() wrapper = wrap_exceptions(raise_exception) self.assertRaisesXmlrpcFault(http_client.CONFLICT, wrapper)
def test_404(self): def raise_exception(*args, **kwargs): from django.db.models import ObjectDoesNotExist raise ObjectDoesNotExist() wrapper = wrap_exceptions(raise_exception) self.assertRaisesXmlrpcFault(http_client.NOT_FOUND, wrapper)
def test_400(self): exceptions = [v for k, v in locals().copy().items() if k != 'self'] exceptions.extend((TypeError, ValueError)) def raise_exception(cls): raise cls() wrapper = wrap_exceptions(raise_exception) for clazz in exceptions: self.assertXmlrpcFaultBadRequest(wrapper, clazz)
def test_400(self): exceptions = [v for k, v in six.iteritems(locals().copy()) if k != 'self'] exceptions.extend((TypeError, ValueError)) def raise_exception(cls): raise cls() wrapper = wrap_exceptions(raise_exception) for clazz in exceptions: self.assertRaisesXmlrpcFault(http_client.BAD_REQUEST, wrapper, clazz)
def test_500(self): def raise_exception(*args, **kwargs): raise Exception() wrapper = wrap_exceptions(raise_exception) try: wrapper() except Fault as f: self.assertEqual(f.faultCode, 500, AssertMessage.SHOULD_BE_500) else: self.fail(AssertMessage.SHOULD_RAISE_EXCEPTION)
def test_409(self): def raise_exception(*args, **kwargs): from django.db.utils import IntegrityError raise IntegrityError() wrapper = wrap_exceptions(raise_exception) try: wrapper() except Fault as f: self.assertEqual(f.faultCode, 409, AssertMessage.SHOULD_BE_409) else: self.fail(AssertMessage.SHOULD_RAISE_EXCEPTION)
def test_404(self): def raise_exception(*args, **kwargs): from django.db.models import ObjectDoesNotExist raise ObjectDoesNotExist() wrapper = wrap_exceptions(raise_exception) try: wrapper() except Fault as f: self.assertEqual(f.faultCode, 404, AssertMessage.SHOULD_BE_404) else: self.fail(AssertMessage.SHOULD_RAISE_EXCEPTION)
def test_403(self): def raise_exception(*args, **kwargs): from django.core.exceptions import PermissionDenied raise PermissionDenied() wrapper = wrap_exceptions(raise_exception) try: wrapper() except Fault as f: self.assertEqual(f.faultCode, 403, AssertMessage.SHOULD_BE_403) else: self.fail(AssertMessage.SHOULD_RAISE_EXCEPTION)
def test_400(self): from django.db.models import FieldDoesNotExist from django.core.exceptions import FieldError from django.core.exceptions import ValidationError from django.core.exceptions import MultipleObjectsReturned exceptions = [v for k, v in locals().iteritems() if k != 'self'] exceptions.extend((TypeError, ValueError)) def raise_exception(cls): raise cls() wrapper = wrap_exceptions(raise_exception) for clazz in exceptions: try: wrapper(clazz) except Fault as f: self.assertEqual(f.faultCode, 400, AssertMessage.SHOULD_BE_400) else: self.fail(AssertMessage.SHOULD_RAISE_EXCEPTION)
def test_501(self): def raise_exception(*args, **kwargs): raise NotImplementedError() wrapper = wrap_exceptions(raise_exception) self.assertXmlrpcFaultNotImplemented(wrapper)
def test_500(self): def raise_exception(*args, **kwargs): raise Exception() wrapper = wrap_exceptions(raise_exception) self.assertXmlrpcFaultInternalServerError(wrapper)
def test_501(self): def raise_exception(*args, **kwargs): raise NotImplementedError() wrapper = wrap_exceptions(raise_exception) self.assertRaisesXmlrpcFault(http_client.NOT_IMPLEMENTED, wrapper)
def test_500(self): def raise_exception(*args, **kwargs): raise Exception() wrapper = wrap_exceptions(raise_exception) self.assertRaisesXmlrpcFault(http_client.INTERNAL_SERVER_ERROR, wrapper)