Пример #1
0
 def test_one_item_fails(self):
     data = {'a': 'some string'}
     schema = ('a', chainable.AllIn(types.string, types.boolean))
     with raises(Invalid) as exc:
         validate(data, schema)
     error = exc.value.args[0]
     assert '-> a -> some string  did not pass validation against callable: AllIn -> boolean' in error
Пример #2
0
 def test_a_validator_fails_with_a_tree_path(self):
     chain = chainable.AllIn(types.boolean, types.string)
     with raises(AssertionError):
         chain("some string")
Пример #3
0
 def test_all_items_pass(self):
     starts = lambda value: True
     data = {'a': 'some string'}
     schema = ('a', chainable.AllIn(types.string, starts))
     assert validate(data, schema) is None
Пример #4
0
 def test_all_validators_pass(self):
     def foo(value): pass
     def bar(value): pass
     chain = chainable.AllIn(foo, bar)
     assert chain('some value') is None