test_general_routes.py 1.41 KiB
import json
import jsonschema
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
"Accept": ["application/json"]
}
def test_version_request(client, mocked_redis):
version_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"latch": {
"type": "object",
"properties": {
"current": {"type": "integer"},
"next": {"type": "integer"},
"this": {"type": "integer"},
"failure": {"type": "boolean"},
"pending": {"type": "boolean"},
},
"required": ["current", "next", "this", "pending", "failure"],
"additionalProperties": False
}
},
"type": "object",
"properties": {
"api": {
"type": "string",
"pattern": r'\d+\.\d+'
},
"module": {
"type": "string",
"pattern": r'\d+\.\d+'
},
"latch": {"$ref": "#/definitions/latch"}
},
"required": ["api", "module"],
"additionalProperties": False
}
rv = client.post(
"version",
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
jsonschema.validate(
json.loads(rv.data.decode("utf-8")),
version_schema)