def test_any_objects_fail_non_callable(self): data = {'a': {'a': 1, 'b': 4, 'c': 3}} schema = ('a', recursive.AnyObject(('a', 'a'))) with raises(Invalid) as exc: validate(data, schema) error = exc.value.args[0] assert '-> a did not contain any valid objects against callable: AnyObject' in error
def test_any_object_fail_all(self): data = {0: ('a', '1'), 1: ('b', '2'), 2: ('c', '3')} schema = ((types.string, types.integer)) with raises(Invalid) as exc: any_object = recursive.AnyObject(schema) any_object(data, []) msg = '-> top level did not contain any valid objects against callable: AnyObject' assert exc.value.args[0] == msg
def test_any_objects_pass(self): data = {'a': {'a': 1, 'b': 'a string', 'c': 3}} schema = ('a', recursive.AnyObject((types.string, types.string))) assert validate(data, schema) is None
def test_any_object_pass_last(self): data = {0: ('a', 1), 1: ('b', 2), 2: ('c', '3')} schema = ((types.string, types.string)) any_object = recursive.AnyObject(schema) assert any_object(data, []) is None