Exemplo n.º 1
0
    def test_map_method_validation(self):
        validation = FieldsValidation()
        fields = ['field1','field2']
        methods = ["POST","PUT","GET","DELETE"]
        target = {}
        validation.map_method_validations(target, fields, methods)

        expected = {
                'POST' : ['field1','field2'],
                'GET' : ['field1','field2'],
                'PUT' : ['field1','field2'],
                'DELETE' : ['field1','field2'],
                }

        self.assertEqual(expected, target)

        validation.map_method_validations(target, ['field3'], ['PUT','POST'])

        expected = {
                'POST' : ['field1','field2','field3'],
                'GET' : ['field1','field2'],
                'PUT' : ['field1','field2','field3'],
                'DELETE' : ['field1','field2'],
                }

        self.assertEqual(expected, target)
Exemplo n.º 2
0
    def test_parse_methods_key(self):
        validation = FieldsValidation()
        key = "required_post"
        #value = ['field1','field2']
        target = {}

        methods = validation.parse_methods_key(key,'required')
        self.assertEqual(['POST'], methods)