def test_validate_recursive(): schema = """\ {"type": "record", "name": "Lisp", "fields": [{"name": "value", "type": ["null", "string", {"type": "record", "name": "Cons", "fields": [{"name": "car", "type": "Lisp"}, {"name": "cdr", "type": "Lisp"}]}]}]} """ datum = {'value': {'car': {'value': 'head'}, 'cdr': {'value': None}}} assert validate(datum, schema)
def test_validate_recursive(): schema = """\ {"type": "record", "name": "Lisp", "fields": [{"name": "value", "type": ["null", "string", {"type": "record", "name": "Cons", "fields": [{"name": "car", "type": "Lisp"}, {"name": "cdr", "type": "Lisp"}]}]}]} """ datum = {'value': {'car': {'value': 'head'}, 'cdr': {'value': None}}} assert validate(datum, schema) == 0
def test_validate_schemas(): for schema, datum, exp_res in TEST_CASES: assert validate(datum, schema) == exp_res