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

added unit test of opsdb.lookup_lg_routers

parent b32a2a7e
No related branches found
No related tags found
No related merge requests found
......@@ -336,7 +336,7 @@ WHERE
def _row2rsp(row):
print(row)
return {
'equipment-name': row['router_name'],
'equipment name': row['router_name'],
'type': 'INTERNAL' if row['pop_name'] in INTERNAL_POP_NAMES else 'CORE',
'pop': {
'name': row['pop_name'],
......
......@@ -144,6 +144,51 @@ CORIANT_PATH_METADATA = {
"additionalProperties": False
}
LG_ROUTERS_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"pop-info": {
"type": "object",
"properties": {
"name": {"type": "string"},
"abbreviation": {"type": "string"},
"country": {"type": "string"},
"country code": {"type": "string"},
"city": {"type": "string"},
"longitude": {"type": "number"},
"latitude": {"type": "number"}
},
"required": [
"name",
"abbreviation",
"country",
"country code",
"city",
"longitude",
"latitude"
],
"additionalProperties": False
},
"router": {
"type": "object",
"properties": {
"equipment name": {"type": "string"},
"type": {
"type": "string",
"enum": ["INTERNAL", "CORE"]
},
"pop": {"$ref": "#/definitions/pop-info"}
},
"required": ["equipment name", "type", "pop"],
"additionalProperties": False
}
},
"type": "array",
"items": {"$ref": "#/definitions/router"}
}
@pytest.mark.parametrize('equipment', [
'mx1.cbg.uk.geant.net',
......@@ -227,3 +272,9 @@ def test_get_all_service_users(connection, cached_test_data):
# services.setdefault(user['service_id'], []).append(user['user'])
#
# print([f'{k}: {v}' for k, v in services.items() if len(v) > 1])
def test_lookup_lg_routers(connection, cached_test_data):
routers = list(opsdb.lookup_lg_routers(connection))
jsonschema.validate(routers, LG_ROUTERS_SCHEMA)
assert routers # 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