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

use updated schema for tests

parent 8da81f7b
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,12 @@ ROUTER_INTERFACES_SCHEMA = {
"type": "object",
"properties": {
"name": {"type": "string"},
"router": {"type": "string"},
"description": {"type": "string"},
"router": {"type": "string"},
"bundle": {
"type": "array",
"items": {"type": "string"}
},
"ipv4": {
"type": "array",
"items": {"type": "string"}
......@@ -31,9 +35,11 @@ ROUTER_INTERFACES_SCHEMA = {
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
# only if not the default
"logical-system": {"type": "string"},
},
"required": ["name", "description", "router", "ipv4", "ipv6"],
"required": ["name", "description", "ipv4", "router", "ipv6"],
"additionalProperties": False
}
}
......
......@@ -3,6 +3,7 @@ import json
import pytest
import jsonschema
from inventory_provider.routes import msr
from inventory_provider.routes.data import ROUTER_INTERFACES_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
......@@ -11,41 +12,13 @@ DEFAULT_REQUEST_HEADERS = {
def test_router_interfaces(router, client):
interfaces_list_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"router": {"type": "string"},
"bundle": {
"type": "array",
"items": {"type": "string"}
},
"ipv4": {
"type": "array",
"items": {"type": "string"}
},
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["name", "description", "ipv4", "router", "ipv6"],
"additionalProperties": False
}
}
rv = client.post(
"/data/interfaces/" + router,
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
response = json.loads(rv.data.decode("utf-8"))
jsonschema.validate(response, interfaces_list_schema)
jsonschema.validate(response, ROUTER_INTERFACES_SCHEMA)
assert response # at least shouldn't be empty
......
......@@ -2,6 +2,9 @@ import contextlib
import json
import jsonschema
from inventory_provider.routes.data \
import ROUTER_INTERFACES_SCHEMA, ROUTERS_RESPONSE_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
"Accept": ["application/json"]
......@@ -9,18 +12,12 @@ DEFAULT_REQUEST_HEADERS = {
def test_get_routers(client):
version_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {"type": "string"}
}
rv = client.post(
"data/routers",
"/data/routers",
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
response = json.loads(rv.data.decode("utf-8"))
jsonschema.validate(response, version_schema)
jsonschema.validate(response, ROUTERS_RESPONSE_SCHEMA)
assert response
......@@ -79,38 +76,11 @@ def test_pop_not_found(client, mocker):
def test_router_interfaces_all(client):
interfaces_list_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"router": {"type": "string"},
"bundle": {
"type": "array",
"items": {"type": "string"}
},
"ipv4": {
"type": "array",
"items": {"type": "string"}
},
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["name", "description", "ipv4", "router", "ipv6"],
"additionalProperties": False
}
}
rv = client.post(
'/data/interfaces',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
response = json.loads(rv.data.decode("utf-8"))
jsonschema.validate(response, interfaces_list_schema)
jsonschema.validate(response, ROUTER_INTERFACES_SCHEMA)
assert response # at least shouldn't be empty
......@@ -30,6 +30,7 @@ def test_load_json_docs(data_config, mocked_redis):
"interface": {
"type": "object",
"properties": {
"logical-system": {"type": "string"},
"name": {"type": "string"},
"description": {"type": "string"},
"bundle": {
......
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