def test_evaluate_ok_no_optional(): ok_json = { "version": "2", "email": "*****@*****.**", "data": { "childbranch": { "price": 18, "subchildbranch": { "id": 555 } }, "Id": 231, } } js = JSONEvaluator(BASE_SCHEMA) js.evaluate(ok_json) assert js.errors == [] assert js.ok
def test_instantiate_with_bad_schema_ok(): with pytest.raises(ValueError): js = JSONEvaluator("bad_json")
def test_instantiate_no_schema_ok(): js = JSONEvaluator() assert isinstance(js, JSONEvaluator)
def test_instantiate_with_schema_ok(): js = JSONEvaluator(BASE_SCHEMA) assert isinstance(js, JSONEvaluator) assert js.ok assert js.errors == []
def test_multiple(schema, input_data, ok, error): js = JSONEvaluator(schema) js.evaluate(input_data) assert js.errors == error assert js.ok == ok