示例#1
0
class MethodValidatorTestCase(unittest.TestCase):
    def setUp(self):
        super(MethodValidatorTestCase, self).setUp()
        self.validator = MethodValidator()

    def test_check_methods(self):
        valid_methods = [
            'get',
        ]
        self.assertIsNone(self.validator.validate(valid_methods))

    def test_check_methods_2(self):
        valid_methods = 'get'
        self.assertIsNone(self.validator.validate(valid_methods))

    def test_check_methods_failed(self):
        invalid_methods = ('get', )
        self.assertRaises(NotSupportedArgumentType, self.validator.validate,
                          invalid_methods)
示例#2
0
class MethodValidatorTestCase(unittest.TestCase):

    def setUp(self):
        super(MethodValidatorTestCase, self).setUp()
        self.validator = MethodValidator()

    def test_check_methods(self):
        valid_methods = ['get', ]
        self.assertIsNone(self.validator.validate(valid_methods))

    def test_check_methods_2(self):
        valid_methods = 'get'
        self.assertIsNone(self.validator.validate(valid_methods))

    def test_check_methods_failed(self):
        invalid_methods = ('get', )
        self.assertRaises(
            NotSupportedArgumentType,
            self.validator.validate, invalid_methods
        )
示例#3
0
        def wrapper():
            class FunctionView(MethodBasedView):
                def handler(self, request, *args, **kwargs):
                    return func(request, *args, **kwargs)

            view = FunctionView

            supported_methods = methods
            method_validator = MethodValidator()
            method_validator.validate(supported_methods)

            if type(supported_methods) is str:
                supported_methods = [supported_methods]

            for method in supported_methods:
                setattr(view, method.lower(), view.handler)

            for attr in attrs:
                setattr(view, str(attr).lower(), attrs[attr])

            return path, view, methods, name
示例#4
0
        def wrapper():
            class FunctionView(MethodBasedView):
                def handler(self, request, *args, **kwargs):
                    return func(request, *args, **kwargs)

            view = FunctionView

            supported_methods = methods
            method_validator = MethodValidator()
            method_validator.validate(supported_methods)

            if type(supported_methods) is str:
                supported_methods = [
                    supported_methods,
                ]

            for method in supported_methods:
                setattr(view, method.lower(), view.handler)

            for attr in attrs:
                setattr(view, str(attr).lower(), attrs[attr])

            return path, view, methods, name
示例#5
0
 def setUp(self):
     super(MethodValidatorTestCase, self).setUp()
     self.validator = MethodValidator()
示例#6
0
 def setUp(self):
     super(MethodValidatorTestCase, self).setUp()
     self.validator = MethodValidator()