本文整理汇总了Python中nova.api.validator.validate函数的典型用法代码示例。如果您正苦于以下问题:Python validate函数的具体用法?Python validate怎么用?Python validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validate
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))
示例2: test_only_tests_intersect
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))
示例3: test_default_validator
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: __call__
def __call__(self, req):
if validator.validate(req.environ['ec2.request'].args,
validator.DEFAULT_VALIDATOR):
return self.application
else:
raise webob.exc.HTTPBadRequest()