Пример #1
0
 def test_default_validator(self):
     expect_pass = {'attribute': 'foobar'}
     self.assertTrue(
         validator.validate(expect_pass, validator.DEFAULT_VALIDATOR))
     expect_fail = {'attribute': 0}
     self.assertFalse(
         validator.validate(expect_fail, validator.DEFAULT_VALIDATOR))
Пример #2
0
    def test_validate(self):
        fixture = {
            'foo': lambda val: val is True
        }

        self.assertTrue(
            validator.validate({'foo': True}, fixture))
        self.assertFalse(
            validator.validate({'foo': False}, fixture))
Пример #3
0
 def test_default_validator(self):
     expect_pass = {
         'attribute': 'foobar'
     }
     self.assertTrue(validator.validate(expect_pass,
                                        validator.DEFAULT_VALIDATOR))
     expect_fail = {
         'attribute': 0
     }
     self.assertFalse(validator.validate(expect_fail,
                                         validator.DEFAULT_VALIDATOR))
Пример #4
0
    def test_only_tests_intersect(self):
        """Test that validator.validate only tests the intersect of keys
        from args and validator.
        """

        fixture = {
            'foo': lambda val: True,
            'bar': lambda val: True
        }

        self.assertTrue(
            validator.validate({'foo': True}, fixture))
        self.assertTrue(
            validator.validate({'foo': True, 'bar': True}, fixture))
        self.assertTrue(
            validator.validate({'foo': True, 'bar': True, 'baz': True},
                               fixture))
Пример #5
0
    def test_only_tests_intersect(self):
        """Test that validator.validate only tests the intersect of keys
        from args and validator.
        """

        fixture = {'foo': lambda val: True, 'bar': lambda val: True}

        self.assertTrue(validator.validate({'foo': True}, fixture))
        self.assertTrue(validator.validate({
            'foo': True,
            'bar': True
        }, fixture))
        self.assertTrue(
            validator.validate({
                'foo': True,
                'bar': True,
                'baz': True
            }, fixture))
Пример #6
0
    def test_validate(self):
        fixture = {'foo': lambda val: val is True}

        self.assertTrue(validator.validate({'foo': True}, fixture))
        self.assertFalse(validator.validate({'foo': False}, fixture))
Пример #7
0
 def __call__(self, req):
     if validator.validate(req.environ['ec2.request'].args,
                           validator.DEFAULT_VALIDATOR):
         return self.application
     else:
         raise webob.exc.HTTPBadRequest()
Пример #8
0
 def __call__(self, req):
     if validator.validate(req.environ['ec2.request'].args,
                           validator.DEFAULT_VALIDATOR):
         return self.application
     else:
         raise webob.exc.HTTPBadRequest()