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

add router response schema validation

parent aafef5e0
No related branches found
No related tags found
No related merge requests found
......@@ -118,9 +118,11 @@ The following resources can be requested from the webservice.
### synchronous resources
All responses are JSON formatted messages.
* `/data/version`
The response will be a JSON message formatted object
The response will be an object
containing the module and protocol versions of the
running server and will be formatted as follows:
......@@ -143,3 +145,16 @@ The following resources can be requested from the webservice.
}
```
* /data/routers
The response will be a list of router hostnames
for which information is available and will be
formatted as follows:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {"type": "string"}
}
```
......@@ -187,7 +187,14 @@ class MockedRedis(object):
return MockedRedis.db.keys()
def test_abc(mocker, client):
def test_routers_list(mocker, client):
routers_list_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {"type": "string"}
}
mocker.patch(
'inventory_provider.router_details.redis.StrictRedis',
MockedRedis)
......@@ -199,5 +206,6 @@ def test_abc(mocker, client):
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
rsp = rv.data.decode("utf-8")
print(rsp)
response = json.loads(rv.data.decode("utf-8"))
jsonschema.validate(response, routers_list_schema)
assert response # shouldn't be empty
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment