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

added negative test case

parent 9722dce3
No related branches found
No related tags found
No related merge requests found
import json import json
import jsonschema import jsonschema
import pytest
from inventory_provider.routes import common from inventory_provider.db.ims_data import NODE_LOCATION_SCHEMA
from inventory_provider.routes.default import VERSION_SCHEMA
DEFAULT_REQUEST_HEADERS = {
'Content-type': 'application/json',
'Accept': ['application/json']
}
def test_version_request(client, mocked_redis):
@pytest.mark.parametrize('equipment_name', [
'MX1.AMS.NL',
'MIL-OLA1',
'LON02-GRV1'
])
def test_location(client, mocked_redis, equipment_name):
rv = client.post( rv = client.post(
'version', f'/neteng/location/{equipment_name}',
headers=DEFAULT_REQUEST_HEADERS) headers={'Accept': ['application/json']})
assert rv.status_code == 200 assert rv.status_code == 200
jsonschema.validate( jsonschema.validate(
json.loads(rv.data.decode('utf-8')), json.loads(rv.data.decode('utf-8')),
VERSION_SCHEMA) NODE_LOCATION_SCHEMA)
def test_load_json_docs(data_config, mocked_redis):
INTERFACE_SCHEMA = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'definitions': { def test_location_not_found(client, mocked_redis):
'interface': { rv = client.post(
'type': 'object', '/neteng/location/BOGUS.EQUIPMENT.NAME',
'properties': { headers={'Accept': ['application/json']})
'logical-system': {'type': 'string'}, assert rv.status_code == 404
'name': {'type': 'string'},
'description': {'type': 'string'},
'bundle': {
'type': 'array',
'items': {'type': 'string'}
},
'ipv4': {
'type': 'array',
'items': {'type': 'string'}
},
'ipv6': {
'type': 'array',
'items': {'type': 'string'}
}
},
'required': ['name', 'description', 'ipv4', 'ipv6'],
'additionalProperties': False
}
},
'type': 'object',
'properties': {
'key': {'type': 'string'},
'value': {'$ref': '#/definitions/interface'}
},
'required': ['key', 'value'],
'additionalProperties': False
}
for ifc in common.load_json_docs(
data_config, 'netconf-interfaces:*', num_threads=20):
jsonschema.validate(ifc, INTERFACE_SCHEMA)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment