Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    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)
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
    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)
Example #14
0
    def test_501(self):
        def raise_exception(*args, **kwargs):
            raise NotImplementedError()

        wrapper = wrap_exceptions(raise_exception)
        self.assertXmlrpcFaultNotImplemented(wrapper)
Example #15
0
    def test_500(self):
        def raise_exception(*args, **kwargs):
            raise Exception()

        wrapper = wrap_exceptions(raise_exception)
        self.assertXmlrpcFaultInternalServerError(wrapper)
Example #16
0
    def test_501(self):
        def raise_exception(*args, **kwargs):
            raise NotImplementedError()

        wrapper = wrap_exceptions(raise_exception)
        self.assertRaisesXmlrpcFault(http_client.NOT_IMPLEMENTED, wrapper)
Example #17
0
    def test_500(self):
        def raise_exception(*args, **kwargs):
            raise Exception()

        wrapper = wrap_exceptions(raise_exception)
        self.assertRaisesXmlrpcFault(http_client.INTERNAL_SERVER_ERROR, wrapper)