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

added test & validation of tnms-fibre-info

parent 929e21f5
No related branches found
Tags 0.90
No related merge requests found
......@@ -107,14 +107,6 @@ def _location_from_equipment(equipment_name: str, r: Redis) -> Optional[dict]:
abbreviation=result[0]['pop']['abbreviation'])
def _location_from_services(services, r: Redis):
for s in services:
loc_a = _location_from_equipment(s['equipment'], r)
loc_b = _location_from_equipment(s['other_end_equipment'], r) \
if s['other_end_equipment'] else None
yield build_locations(loc_a, loc_b)
class ClassifierRequestError(Exception):
status_code = 500
......@@ -694,11 +686,14 @@ def get_trap_metadata(source_equipment: str, interface: str, circuit_id: str) \
r
))
# rubbish hack to cope with Dashboard Classifier removing piece of
# interface name. Once Dashboard is fully driven by IMS we can remove that # noqa
# rubbish hack to cope with Dashboard Classifier
# removing piece of interface name. Once Dashboard
# is fully driven by IMS we can remove that
# part of the classifier and then this
# As of 2021-04-21 the Dashboard line that will need removing is
# https://gitlab.geant.net/live-projects/dashboardv3/dashboard-v3-python/-/blob/develop/dashboard/classification/classifier.py#L207 # noqa
# https://gitlab.geant.net/live-projects/dashboardv3/dashboard-v3-python/-/blob/develop/dashboard/classification/classifier.py#L207 # noqa: E501
if not result or not result.get('services', []):
interface_parts = interface.split('-')
interface_parts[-2] = 'T' + interface_parts[-2]
......@@ -890,11 +885,13 @@ def get_tnms_fibre_trap_metadata(enms_pc_name: str) -> Response:
Handler for /classifier/infinera-fiberlink-info that
returns metadata for a particular opitical path segment.
TODO: no schema is declared, and there are no validation tests
The response will be formatted according to the following schema:
.. asjson::
inventory_provider.routes.classifier_schema.TNMS_FIBERLINK_INFO_RESPONSE_SCHEMA
:param enms_pc_name: both node names separated by a forward slash
:return:
"""
""" # noqa: E501
r = common.get_current_redis()
......
......@@ -8,7 +8,8 @@ _common_ims_schema_definitions = {
"installed",
"operational",
"terminated",
"disposed"]
"disposed",
'non-monitored']
}
}
......@@ -20,7 +21,8 @@ _common_schema_definitions = {
"installed",
"operational",
"terminated",
"disposed"]
"disposed",
'non-monitored']
},
"service": {
"type": "object",
......@@ -259,7 +261,6 @@ _juniper_link_response_schema_definitions = {
JUNIPER_LINK_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
**_juniper_link_response_schema_definitions,
......@@ -410,7 +411,6 @@ _peer_info_response_schema_definitions = {
PEER_INFO_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
**_peer_info_response_schema_definitions,
......@@ -506,7 +506,7 @@ _infinera_lambda_response_schema_definitions = {
"project": {"type": "string"}
},
"required": [
"name", "status", "circuit_type", "sservice_type", "project"],
"name", "status", "circuit_type", "service_type", "project"],
"additionalProperties": False
},
"geant-lambda": {
......@@ -526,7 +526,6 @@ _infinera_lambda_response_schema_definitions = {
INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
**_infinera_lambda_response_schema_definitions,
......@@ -558,7 +557,6 @@ INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA = {
MTC_INTERFACE_INFO_RESPONSE_SCHEMA = INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA
INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
**_common_schema_definitions
......@@ -585,7 +583,6 @@ INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA = {
CORIANT_INFO_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
......@@ -648,3 +645,80 @@ CORIANT_INFO_RESPONSE_SCHEMA = {
"required": ["equipment name", "card id", "port number"],
"additionalProperties": False
}
TNMS_FIBERLINK_INFO_RESPONSE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
'definitions': {
'link-endpoint': {
'type': 'object',
'properties': {
'equipment': {'type': 'string'},
'name': {'type': 'string'},
'abbreviation': {'type': 'string'}
},
'required': ['equipment', 'name', 'abbreviation'],
'additionalProperties': False
},
'link-location': {
'type': 'object',
'properties': {
'a': {'$ref': '#/definitions/link-endpoint'},
'b': {'$ref': '#/definitions/link-endpoint'}
},
'required': ['a', 'b'],
'additionalProperties': False
},
'circuit-endpoint': {
'type': 'object',
'properties': {
'pop': {'type': 'string'},
'pop_abbreviation': {'type': 'string'},
'equipment': {'type': 'string'},
},
'required': ['pop', 'pop_abbreviation', 'equipment'],
'additionalProperties': False
},
'circuit-location': {
'type': 'object',
'properties': {
'a': {'$ref': '#/definitions/circuit-endpoint'},
'b': {'$ref': '#/definitions/circuit-endpoint'}
},
'required': ['a', 'b'],
'additionalProperties': False
},
'df-route': {
'type': 'object',
'properties': {
'id': {'type': 'integer'},
'name': {'type': 'string'},
'status': {
'type': 'string',
'enum': ['operational', 'non-monitored']
}
},
'required': ['id', 'name', 'status'],
'additionalProperties': False
}
},
'type': 'object',
'properties': {
'locations': {
'type': 'array',
'items': {'$ref': '#/definitions/link-location'},
'minItems': 1,
'maxItems': 1
},
'ends': {'$ref': '#/definitions/circuit-location'},
'df_route': {'$ref': '#/definitions/df-route'},
'related-services': {'type': 'array'}, # TODO
'contacts': {'type': 'array'} # TODO
},
'required': [
'locations', 'ends', 'df_route', 'related-services', 'contacts'],
'additionalProperties': False
}
......@@ -5,7 +5,8 @@ import pytest
from inventory_provider.routes.classifier_schema \
import JUNIPER_LINK_RESPONSE_SCHEMA, PEER_INFO_RESPONSE_SCHEMA, \
INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA, CORIANT_INFO_RESPONSE_SCHEMA, \
INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA, MTC_INTERFACE_INFO_RESPONSE_SCHEMA
INFINERA_FIBERLINK_INFO_RESPONSE_SCHEMA, \
MTC_INTERFACE_INFO_RESPONSE_SCHEMA, TNMS_FIBERLINK_INFO_RESPONSE_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
......@@ -198,3 +199,13 @@ def test_infinera_lambda(client):
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA)
def test_tnms_fibre_info(client):
rv = client.get(
'/classifier/tnms-fibre-info/SWENSZAB-MTC9-1/ZRCHSZ01-MTC9-1',
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
assert rv.is_json
response_data = json.loads(rv.data.decode('utf-8'))
jsonschema.validate(response_data, TNMS_FIBERLINK_INFO_RESPONSE_SCHEMA)
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