From 8e5ffe6e8bb741508efbb2e49d0bd6b54b7c5750 Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Fri, 17 Apr 2020 14:31:37 +0200 Subject: [PATCH] added sanity check test of opsdb.get_circuits --- test/test_opsdb_queries.py | 77 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/test_opsdb_queries.py b/test/test_opsdb_queries.py index dd45730e..e9a04929 100644 --- a/test/test_opsdb_queries.py +++ b/test/test_opsdb_queries.py @@ -278,3 +278,80 @@ 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 + + +CIRCUIT_INFO_SCHEMA = { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + + "type": "object", + "properties": { + "id": {"type": "integer"}, + "name": {"type": "string"}, + "status": { + "type": "string", + "enum": ["operational", "installed", "planned", "ordered"] + }, + "circuit_type": { + "type": "string", + "enum": ["path", "service", "l2circuit", "link-aggr-group"] + }, + "service_type": {"type": "string"}, + "project": {"type": "string"}, + "equipment": {"type": "string"}, + "pop": {"type": "string"}, + "pop_abbreviation": {"type": "string"}, + + "other_end_pop": {"type": "string"}, + "other_end_pop_abbreviation": {"type": "string"}, + "other_end_equipment": {"type": "string"}, + "port": {"type": "string"}, + "other_end_port": {"type": "string"}, + "logical_unit": { + "oneOf": [ + {"type": "integer"}, + {"type": "string", "maxLength": 0} + ] + }, + "other_end_logical_unit": { + "oneOf": [ + {"type": "integer"}, + {"type": "string", "maxLength": 0} + ] + }, + "manufacturer": { + "type": "string", + "enum": ["juniper", "coriant", "infinera", + "cisco", "hewlett packard", + "corsa", "graham smith uk ltd", + "intel", "dell", "mellanox technologies", + "unknown", ""] + }, + "card_id": {"type": "string"}, + "other_end_card_id": {"type": "string"}, + "interface_name": {"type": "string"}, + "other_end_interface_name": {"type": "string"}, + + # TODO: check what's changed: added to make tests pass + 'other_end_pop_name': {"type": "string"}, + 'pop_name': {"type": "string"} + }, + "required": [ + "id", "name", "status", "circuit_type", + "service_type", "project", + "equipment", "other_end_equipment", + "card_id", "other_end_card_id", + "port", "other_end_port", + "logical_unit", "other_end_logical_unit", + "interface_name", "other_end_interface_name" + # "pop", "other_end_pop", + # "pop_name", "other_end_pop_name", + # "pop_abbreviation", "other_end_pop_abbreviation", + ], + "additionalProperties": False +} + +def test_get_circuits(connection, cached_test_data): + import re + for circuit in opsdb.get_circuits(connection): + jsonschema.validate(circuit, CIRCUIT_INFO_SCHEMA) -- GitLab