diff --git a/test/test_infinera_classifier.py b/test/test_infinera_classifier.py new file mode 100644 index 0000000000000000000000000000000000000000..81d36d2329b02446e2ba0b0a14b87e3447e4abe4 --- /dev/null +++ b/test/test_infinera_classifier.py @@ -0,0 +1,96 @@ +import json +import jsonschema + +DEFAULT_REQUEST_HEADERS = { + "Content-type": "application/json", + "Accept": ["application/json"] +} + + +INFINERA_LINK_METADATA = { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + + "definitions": { + "service-info": { + "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"] + }, + "service_type": {"type": "string"}, + "project": {"type": "string"}, + "equipment": {"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", + "unknown", ""] + }, + "card_id": {"type": "string"}, + "other_end_card_id": {"type": "string"}, + "interface_name": {"type": "string"}, + "other_end_interface_name": {"type": "string"} + }, + "additionalProperties": False + }, + "geant-lambdas": { + "type": "object", + "properties": { + "id": {"type": "integer"}, + "name": {"type": "string"}, + "status": { + "type": "string", + "enum": ["operational", "installed", "planned", "ordered"] + }, + }, + "additionalProperties": False + } + }, + + "type": "object", + "properties": { + "services": { + "type": "array", + "items": {"$ref": "#/definitions/service-info"} + }, + "geant-lambdas": { + "type": "array", + "items": {"$ref": "#/definitions/geant-lambdas"} + }, + }, + "additionalProperties": False +} + + +def test_trap_metadata(client_with_mocked_data): + rv = client_with_mocked_data.get( + '/infinera-classifier/trap-metadata/LON01-DTNX10-1/1-B-2-1-3', + 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, INFINERA_LINK_METADATA)