diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 1673e80744ec617f0cd2c120f751dc5416a70f76..15b54765fcc2ce6ecf2efc65b52df43de3f3b2f2 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -39,11 +39,23 @@ def _location_from_router(router_name): if not result: logger.error(f'error looking up location for {router_name}') return None + # return { + # 'a': _LOCATION( + # equipment=router_name, + # name='?', + # abbreviation='?') + # } result = json.loads(result.decode('utf-8')) if not result: logger.error(f'sanity failure: empty list for location {router_name}') return None + # return { + # 'a': _LOCATION( + # equipment=router_name, + # name='?', + # abbreviation='?') + # } return { 'a': _LOCATION( diff --git a/test/test_classifier_routes.py b/test/test_classifier_routes.py index 4afac35968354d664183242e34654c3907e18cab..a255809613f447d655485f02c1efaca3cb8f0d25 100644 --- a/test/test_classifier_routes.py +++ b/test/test_classifier_routes.py @@ -30,7 +30,8 @@ LOCATIONS_DEFINITIONS = { }, "locations-list": { "type": "array", - "items": {"$ref": "#/definitions/location"} + "items": {"$ref": "#/definitions/location"}, + "minitems": 1 } } @@ -174,7 +175,7 @@ JUNIPER_LINK_METADATA = { }, "locations": {"$ref": "#/definitions/locations-list"} }, - # "required": ["interface"], + "required": ["interface", "locations"], "additionalProperties": False } @@ -216,6 +217,33 @@ def test_juniper_link_info_not_found(client): } +def test_juniper_link_unknown_router(client): + rv = client.get( + '/classifier/juniper-link-info/' + 'unknown-router/unknown-interface-name', + 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, JUNIPER_LINK_METADATA) + assert response_data == { + 'interface': { + 'name': 'unknown-interface-name', + 'description': '', + 'ipv4': [], + 'ipv6': [], + 'bundle': [], + 'bundle_members': [] + }, + 'locations': [{ + 'a': { + 'equipment': 'unknown-router', + 'name': '?', + 'abbreviation': '?'} + }] + } + + VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info', 'locations'} IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'interfaces', 'locations'}