예제 #1
0
def test_decode_incorrect_json():
    body = json.dumps({"invalid": "json"})
    validator = Validator(test_schema)
    with pytest.raises(RequestDecodeError):
        decode(body, validator)
예제 #2
0
def test_decode():
    body_str = json.dumps(test_body)
    validator = Validator(test_schema)
    data = decode(body_str, validator)
    assert data == test_body
예제 #3
0
def test_decode_not_json():
    body = "not-json"
    with pytest.raises(RequestDecodeError):
        decode(body, None)