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