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
No related branches found
No related tags found
No related merge requests found
......@@ -8,11 +8,31 @@ DEFAULT_REQUEST_HEADERS = {
"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 = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
"location": LOCATION_DEFINITION,
"ip-address": {
"type": "string",
"oneOf": [
......@@ -123,6 +143,10 @@ JUNIPER_LINK_METADATA = {
"related-services": {
"type": "array",
"items": {"$ref": "#/definitions/service-info"}
},
"locations": {
"type": "array",
"items": {"$ref": "#/definitions/location"}
}
},
# "required": ["interface"],
......@@ -156,12 +180,18 @@ def test_juniper_link_info_not_found(client):
'ipv4': [],
'ipv6': [],
'bundle': []
}
},
'locations': [{
'a': {
'equipment': 'mx1.ams.nl.geant.net',
'name': 'Amsterdam',
'abbreviation': 'ams'}
}]
}
VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info'}
IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'interfaces'}
VPN_RR_PEER_INFO_KEYS = {'vpn-rr-peer-info', 'locations'}
IX_PUBLIC_PEER_INFO_KEYS = {'ix-public-peer-info', 'interfaces', 'locations'}
@pytest.mark.parametrize('peer_address,expected_response_keys', [
......@@ -178,6 +208,7 @@ def test_peer_info(
"type": "object",
"definitions": {
"location": LOCATION_DEFINITION,
"ip-address": {
"type": "string",
"oneOf": [
......@@ -272,6 +303,10 @@ def test_peer_info(
"interfaces": {
"type": "array",
"items": {"$ref": "#/definitions/interface-lookup-info"}
},
"locations": {
"type": "array",
"items": {"$ref": "#/definitions/location"}
}
},
"additionalProperties": False
......@@ -301,7 +336,7 @@ def test_peer_not_found(client):
headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200
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', [
......@@ -325,7 +360,27 @@ def test_coriant_info(
'inventory_provider.db.db.connection', mocked_connection)
mocker.patch(
'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(
'/classifier/coriant-info/{equipment}/{entity}'.format(
......@@ -346,8 +401,14 @@ def test_coriant_info(
'C': CONNECTION,
'E': equipment,
'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
......
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