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

updated test to match new rsp schema

parent 885ec8db
Branches
Tags
No related merge requests found
...@@ -8,11 +8,31 @@ DEFAULT_REQUEST_HEADERS = { ...@@ -8,11 +8,31 @@ DEFAULT_REQUEST_HEADERS = {
"Accept": ["application/json"] "Accept": ["application/json"]
} }
LOCATION_END_DEFINITION = {
"type": "object",
"properties": {
"equipment": {"type": "string"},
"name": {"type": "string"},
"abbreviation": {"type": "string"}
},
"required": ["equipment", "name", "abbreviation"],
"additionalProperties": False
}
LOCATION_DEFINITION = {
"type": "object",
"properties": {
"a": LOCATION_END_DEFINITION,
"b": LOCATION_END_DEFINITION
},
"required": ["a"],
"additionalProperties": False
}
JUNIPER_LINK_METADATA = { JUNIPER_LINK_METADATA = {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"type": "object", "type": "object",
"definitions": { "definitions": {
"location": LOCATION_DEFINITION,
"ip-address": { "ip-address": {
"type": "string", "type": "string",
"oneOf": [ "oneOf": [
...@@ -123,6 +143,10 @@ JUNIPER_LINK_METADATA = { ...@@ -123,6 +143,10 @@ JUNIPER_LINK_METADATA = {
"related-services": { "related-services": {
"type": "array", "type": "array",
"items": {"$ref": "#/definitions/service-info"} "items": {"$ref": "#/definitions/service-info"}
},
"locations": {
"type": "array",
"items": {"$ref": "#/definitions/location"}
} }
}, },
# "required": ["interface"], # "required": ["interface"],
...@@ -156,12 +180,18 @@ def test_juniper_link_info_not_found(client): ...@@ -156,12 +180,18 @@ def test_juniper_link_info_not_found(client):
'ipv4': [], 'ipv4': [],
'ipv6': [], 'ipv6': [],
'bundle': [] 'bundle': []
} },
'locations': [{
'a': {
'equipment': 'mx1.ams.nl.geant.net',
'name': 'Amsterdam',
'abbreviation': 'ams'}
}]
} }
VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info'} VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info', 'locations'}
IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'interfaces'} IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'interfaces', 'locations'}
@pytest.mark.parametrize('peer_address,expected_response_keys', [ @pytest.mark.parametrize('peer_address,expected_response_keys', [
...@@ -178,6 +208,7 @@ def test_peer_info( ...@@ -178,6 +208,7 @@ def test_peer_info(
"type": "object", "type": "object",
"definitions": { "definitions": {
"location": LOCATION_DEFINITION,
"ip-address": { "ip-address": {
"type": "string", "type": "string",
"oneOf": [ "oneOf": [
...@@ -272,6 +303,10 @@ def test_peer_info( ...@@ -272,6 +303,10 @@ def test_peer_info(
"interfaces": { "interfaces": {
"type": "array", "type": "array",
"items": {"$ref": "#/definitions/interface-lookup-info"} "items": {"$ref": "#/definitions/interface-lookup-info"}
},
"locations": {
"type": "array",
"items": {"$ref": "#/definitions/location"}
} }
}, },
"additionalProperties": False "additionalProperties": False
...@@ -301,7 +336,7 @@ def test_peer_not_found(client): ...@@ -301,7 +336,7 @@ def test_peer_not_found(client):
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
response_data = json.loads(rv.data.decode('utf-8')) response_data = json.loads(rv.data.decode('utf-8'))
assert response_data == {} assert response_data == {'locations': []}
@pytest.mark.parametrize('id_,equipment,entity_name,card_id,port_number', [ @pytest.mark.parametrize('id_,equipment,entity_name,card_id,port_number', [
...@@ -325,7 +360,27 @@ def test_coriant_info( ...@@ -325,7 +360,27 @@ def test_coriant_info(
'inventory_provider.db.db.connection', mocked_connection) 'inventory_provider.db.db.connection', mocked_connection)
mocker.patch( mocker.patch(
'inventory_provider.db.opsdb.lookup_coriant_path', 'inventory_provider.db.opsdb.lookup_coriant_path',
lambda a, b, c, d: {'id': '123', 'C': a, 'E': b, 'CID': c, 'P': d}) lambda a, b, c, d: {
'id': '123',
'C': a,
'E': b,
'CID': c,
'P': d,
'a': {
'equipment name': 'abc',
'pop': {
'name': 'zzz',
'abbreviation': '123'
}
},
'b': {
'equipment name': 'ddd',
'pop': {
'name': 'aaa',
'abbreviation': '999'
}
}
})
rv = client.get( rv = client.get(
'/classifier/coriant-info/{equipment}/{entity}'.format( '/classifier/coriant-info/{equipment}/{entity}'.format(
...@@ -346,8 +401,14 @@ def test_coriant_info( ...@@ -346,8 +401,14 @@ def test_coriant_info(
'C': CONNECTION, 'C': CONNECTION,
'E': equipment, 'E': equipment,
'CID': card_id, 'CID': card_id,
'P': port_number 'P': port_number,
} 'a': {'equipment name': 'abc', 'pop': {'name': 'zzz', 'abbreviation': '123'}},
'b': {'equipment name': 'ddd', 'pop': {'name': 'aaa', 'abbreviation': '999'}}
},
'locations': [{
'a': {'equipment': 'abc', 'name': 'zzz', 'abbreviation': '123'},
'b': {'equipment': 'ddd', 'name': 'aaa', 'abbreviation': '999'}
}]
} }
assert response_data == expected_response assert response_data == expected_response
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment