예제 #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()