Пример #1
0
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
Пример #2
0
def test_instantiate_with_bad_schema_ok():
    with pytest.raises(ValueError):
        js = JSONEvaluator("bad_json")
Пример #3
0
def test_instantiate_no_schema_ok():
    js = JSONEvaluator()
    assert isinstance(js, JSONEvaluator)
Пример #4
0
def test_instantiate_with_schema_ok():
    js = JSONEvaluator(BASE_SCHEMA)
    assert isinstance(js, JSONEvaluator)
    assert js.ok
    assert js.errors == []
Пример #5
0
def test_multiple(schema, input_data, ok, error):
    js = JSONEvaluator(schema)
    js.evaluate(input_data)
    assert js.errors == error
    assert js.ok == ok