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)
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 )
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
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
def setUp(self): super(MethodValidatorTestCase, self).setUp() self.validator = MethodValidator()