Skip to content
Snippets Groups Projects
Commit 2a09da27 authored by Erik Reid's avatar Erik Reid
Browse files

validate version response format

parent e418b449
No related branches found
No related tags found
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment