diff --git a/test/test_data_routes.py b/test/test_data_routes.py index 3f4691417e4dbe92dc97fc72950a5852b3ebe829..617e89e6ff5cb1fd425f04dae0e264b5fa06f46d 100644 --- a/test/test_data_routes.py +++ b/test/test_data_routes.py @@ -4,10 +4,11 @@ import os import tempfile import pytest +import jsonschema import inventory_provider -logging.basicConfig(level=logging.DEBUG) +# logging.basicConfig(level=logging.DEBUG) DEFAULT_REQUEST_HEADERS = { "Content-type": "application/json", @@ -132,10 +133,27 @@ def client(app_config): def test_version_request(client): + version_schema = { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "api": { + "type": "string", + "pattern": r'\d+\.\d+' + }, + "module": { + "type": "string", + "pattern": r'\d+\.\d+' + } + }, + "required": ["api", "module"], + "additionalProperties": False + } + rv = client.post( "data/version", headers=DEFAULT_REQUEST_HEADERS) assert rv.status_code == 200 - logging.debug("rv.data: '%s'" % rv.data.decode("utf-8")) - print(rv.data.decode("utf-8")) - # validate(json.loads(rv.data.decode("utf-8")), SERVICES_SCHEMA) + jsonschema.validate( + json.loads(rv.data.decode("utf-8")), + version_schema)