Skip to content
Snippets Groups Projects
Commit 669e787c authored by Robert Latta's avatar Robert Latta
Browse files

updated endpoints for original opsdb based tests

parent b00cb196
Branches
Tags my_prenew_tomas mytomas
No related merge requests found
...@@ -39,7 +39,7 @@ def test_router_interfaces(router, client): ...@@ -39,7 +39,7 @@ def test_router_interfaces(router, client):
} }
rv = client.post( rv = client.post(
"/data/interfaces/" + router, "/orig-data/interfaces/" + router,
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
......
...@@ -4,7 +4,8 @@ import jsonschema ...@@ -4,7 +4,8 @@ import jsonschema
import pytest import pytest
from inventory_provider.routes.classifier_schema \ from inventory_provider.routes.classifier_schema \
import JUNIPER_LINK_RESPONSE_SCHEMA, PEER_INFO_RESPONSE_SCHEMA import JUNIPER_LINK_RESPONSE_SCHEMA, PEER_INFO_RESPONSE_SCHEMA, \
INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA
DEFAULT_REQUEST_HEADERS = { DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json", "Content-type": "application/json",
...@@ -14,7 +15,7 @@ DEFAULT_REQUEST_HEADERS = { ...@@ -14,7 +15,7 @@ DEFAULT_REQUEST_HEADERS = {
def test_juniper_link_info(client): def test_juniper_link_info(client):
rv = client.get( rv = client.get(
'/classifier/juniper-link-info/mx1.ams.nl.geant.net/ae16.100', '/orig-classifier/juniper-link-info/mx1.ams.nl.geant.net/ae16.100',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.is_json assert rv.is_json
...@@ -24,7 +25,7 @@ def test_juniper_link_info(client): ...@@ -24,7 +25,7 @@ def test_juniper_link_info(client):
def test_juniper_link_info_not_found(client): def test_juniper_link_info_not_found(client):
rv = client.get( rv = client.get(
'/classifier/juniper-link-info/' '/orig-classifier/juniper-link-info/'
'mx1.ams.nl.geant.net/unknown-interface-name', 'mx1.ams.nl.geant.net/unknown-interface-name',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
...@@ -51,7 +52,7 @@ def test_juniper_link_info_not_found(client): ...@@ -51,7 +52,7 @@ def test_juniper_link_info_not_found(client):
def test_juniper_link_unknown_router(client): def test_juniper_link_unknown_router(client):
rv = client.get( rv = client.get(
'/classifier/juniper-link-info/' '/orig-classifier/juniper-link-info/'
'unknown-router/unknown-interface-name', 'unknown-router/unknown-interface-name',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
...@@ -91,7 +92,7 @@ def test_peer_info( ...@@ -91,7 +92,7 @@ def test_peer_info(
client, peer_address, expected_response_keys): client, peer_address, expected_response_keys):
rv = client.get( rv = client.get(
'/classifier/peer-info/%s' % peer_address, '/orig-classifier/peer-info/%s' % peer_address,
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.is_json assert rv.is_json
...@@ -103,14 +104,14 @@ def test_peer_info( ...@@ -103,14 +104,14 @@ def test_peer_info(
def test_peer_invalid_address(client): def test_peer_invalid_address(client):
rv = client.get( rv = client.get(
'/classifier/peer-info/1.2.3.4.5', '/orig-classifier/peer-info/1.2.3.4.5',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 422 assert rv.status_code == 422
def test_peer_not_found(client): def test_peer_not_found(client):
rv = client.get( rv = client.get(
'/classifier/peer-info/1.2.3.4', '/orig-classifier/peer-info/1.2.3.4',
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'))
...@@ -163,7 +164,7 @@ def test_coriant_info( ...@@ -163,7 +164,7 @@ def test_coriant_info(
}) })
rv = client.get( rv = client.get(
'/classifier/coriant-info/{equipment}/{entity}'.format( '/orig-classifier/coriant-info/{equipment}/{entity}'.format(
equipment=equipment, equipment=equipment,
entity=entity_name), entity=entity_name),
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
...@@ -214,7 +215,7 @@ def test_coriant_info_not_found(client, mocker): ...@@ -214,7 +215,7 @@ def test_coriant_info_not_found(client, mocker):
lambda a, b, c, d: None) lambda a, b, c, d: None)
rv = client.get( rv = client.get(
'/classifier/coriant-info/aaa/unparseableentitystring', '/orig-classifier/coriant-info/aaa/unparseableentitystring',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 404 assert rv.status_code == 404
...@@ -222,19 +223,19 @@ def test_coriant_info_not_found(client, mocker): ...@@ -222,19 +223,19 @@ def test_coriant_info_not_found(client, mocker):
def test_infinera_unparseable_fiberlink(client): def test_infinera_unparseable_fiberlink(client):
rv = client.get( rv = client.get(
'/classifier/infinera-fiberlink-info/unparseableentitystring/aaa', '/orig-classifier/infinera-fiberlink-info/unparseableentitystring/aaa',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 422 assert rv.status_code == 422
rv = client.get( rv = client.get(
'/classifier/infinera-fiberlink-info/XXX-OLA1-XXX02-DTNX10-1/aaa', '/orig-classifier/infinera-fiberlink-info/XXX-OLA1-XXX02-DTNX10-1/aaa',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 422 assert rv.status_code == 422
def test_infinera_fiberlink_not_found(client): def test_infinera_fiberlink_not_found(client):
rv = client.get( rv = client.get(
'/classifier/infinera-fiberlink-info/' '/orig-classifier/infinera-fiberlink-info/'
'XXX-OLA1-XXX02-DTNX10-1/1-A-2-L1_3-A-2-L1', 'XXX-OLA1-XXX02-DTNX10-1/1-A-2-L1_3-A-2-L1',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 404 assert rv.status_code == 404
...@@ -254,7 +255,7 @@ def test_infinera_fiberlink(client, mocker): ...@@ -254,7 +255,7 @@ def test_infinera_fiberlink(client, mocker):
'inventory_provider.routes.classifier.get_top_level_services') 'inventory_provider.routes.classifier.get_top_level_services')
mocked_tls.return_value = {'a': 'A'} mocked_tls.return_value = {'a': 'A'}
rv = client.get( rv = client.get(
'/classifier/infinera-fiberlink-info/' '/orig-classifier/infinera-fiberlink-info/'
'XXX-OLA1-XXX02-DTNX10-1/1-A-2-L1_3-A-2-L1', 'XXX-OLA1-XXX02-DTNX10-1/1-A-2-L1_3-A-2-L1',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
mg.assert_any_call( mg.assert_any_call(
...@@ -286,3 +287,14 @@ def test_infinera_fiberlink(client, mocker): ...@@ -286,3 +287,14 @@ def test_infinera_fiberlink(client, mocker):
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.get_data(as_text=True) == json.dumps(expected) assert rv.get_data(as_text=True) == json.dumps(expected)
def test_infinera_lambda(client):
rv = client.get(
'/orig-classifier/infinera-lambda-info/'
'LON2-DTNX10-1/1-A-2-1-4/gen-lon3_LHC_CERN-JANET_09013',
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_LAMBDA_INFO_RESPONSE_SCHEMA)
...@@ -16,7 +16,7 @@ def test_get_routers(client): ...@@ -16,7 +16,7 @@ def test_get_routers(client):
} }
rv = client.post( rv = client.post(
"data/routers", "orig-data/routers",
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
response = json.loads(rv.data.decode("utf-8")) response = json.loads(rv.data.decode("utf-8"))
...@@ -45,7 +45,7 @@ def test_pop_info(client, mocker): ...@@ -45,7 +45,7 @@ def test_pop_info(client, mocker):
lambda c, e: {'C': c, 'E': e}) lambda c, e: {'C': c, 'E': e})
rv = client.get( rv = client.get(
'/data/pop/{E}'.format(**expected_pop_info), '/orig-data/pop/{E}'.format(**expected_pop_info),
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
...@@ -71,7 +71,7 @@ def test_pop_not_found(client, mocker): ...@@ -71,7 +71,7 @@ def test_pop_not_found(client, mocker):
lambda a, b: None) lambda a, b: None)
rv = client.get( rv = client.get(
'/data/pop/aabbcc', '/orig-data/pop/aabbcc',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 404 assert rv.status_code == 404
...@@ -107,7 +107,7 @@ def test_router_interfaces_all(client): ...@@ -107,7 +107,7 @@ def test_router_interfaces_all(client):
} }
rv = client.post( rv = client.post(
'/data/interfaces', '/orig-data/interfaces',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
......
...@@ -37,7 +37,7 @@ def test_get_fibre_info(mocker): ...@@ -37,7 +37,7 @@ def test_get_fibre_info(mocker):
"circuit_id": 659616, "circuit_id": 659616,
"df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)", "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
"df_route_id": 662153, "df_route_id": 662153,
"df_status": "Operational", "df_status": "operational",
"ne": "BUD01-DTNX10-1-3" "ne": "BUD01-DTNX10-1-3"
} }
], ],
...@@ -46,7 +46,7 @@ def test_get_fibre_info(mocker): ...@@ -46,7 +46,7 @@ def test_get_fibre_info(mocker):
"circuit_id": 659617, "circuit_id": 659617,
"df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)", "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
"df_route_id": 662153, "df_route_id": 662153,
"df_status": "Operational", "df_status": "operational",
"ne": "KOM-OLA1-1" "ne": "KOM-OLA1-1"
} }
], ],
...@@ -55,7 +55,7 @@ def test_get_fibre_info(mocker): ...@@ -55,7 +55,7 @@ def test_get_fibre_info(mocker):
"circuit_id": 659616, "circuit_id": 659616,
"df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)", "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
"df_route_id": 662153, "df_route_id": 662153,
"df_status": "Operational", "df_status": "operational",
"ne": "SZE-OLA1-1" "ne": "SZE-OLA1-1"
} }
], ],
...@@ -64,7 +64,7 @@ def test_get_fibre_info(mocker): ...@@ -64,7 +64,7 @@ def test_get_fibre_info(mocker):
"circuit_id": 659617, "circuit_id": 659617,
"df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)", "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
"df_route_id": 662153, "df_route_id": 662153,
"df_status": "Operational", "df_status": "operational",
"ne": "ZAG01-DTNX10-1-2" "ne": "ZAG01-DTNX10-1-2"
} }
] ]
...@@ -101,7 +101,7 @@ def test_lookup_lg_routers(mocker): ...@@ -101,7 +101,7 @@ def test_lookup_lg_routers(mocker):
ds.get_filtered_entities.assert_called_once_with( ds.get_filtered_entities.assert_called_once_with(
'EquipmentDefinition', 'EquipmentDefinition',
'Name like mx', 'Name like MX',
inventory_provider.db.ims.EQUIP_DEF_PROPERTIES['Nodes']) inventory_provider.db.ims.EQUIP_DEF_PROPERTIES['Nodes'])
assert ds.get_entity_by_id.call_count == 35 assert ds.get_entity_by_id.call_count == 35
......
import json
import jsonschema
from inventory_provider.routes.classifier_schema \
import INFINERA_LAMBDA_INFO_RESPONSE_SCHEMA
DEFAULT_REQUEST_HEADERS = {
"Content-type": "application/json",
"Accept": ["application/json"]
}
def test_trap_metadata(client):
rv = client.get(
'/classifier/infinera-lambda-info/'
'LON2-DTNX10-1/1-A-2-1-4/gen-lon3_LHC_CERN-JANET_09013',
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_LAMBDA_INFO_RESPONSE_SCHEMA)
...@@ -29,7 +29,7 @@ def test_job_update_all(client, mocker): ...@@ -29,7 +29,7 @@ def test_job_update_all(client, mocker):
launch_refresh_cache_all.return_value = expected_task_id launch_refresh_cache_all.return_value = expected_task_id
rv = client.post( rv = client.post(
'jobs/update', 'orig-jobs/update',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
refresh_task_response = json.loads(rv.data.decode('utf-8')) refresh_task_response = json.loads(rv.data.decode('utf-8'))
...@@ -52,7 +52,7 @@ def test_job_update_force_pending(client, mocker): ...@@ -52,7 +52,7 @@ def test_job_update_force_pending(client, mocker):
mocked_get_latch.return_value = {'pending': True} mocked_get_latch.return_value = {'pending': True}
rv = client.post( rv = client.post(
'jobs/update?force=true', 'orig-jobs/update?force=true',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
refresh_task_response = json.loads(rv.data.decode('utf-8')) refresh_task_response = json.loads(rv.data.decode('utf-8'))
...@@ -72,7 +72,7 @@ def test_job_update_pending_force_false(client, mocker): ...@@ -72,7 +72,7 @@ def test_job_update_pending_force_false(client, mocker):
mocked_get_latch.return_value = {'pending': True} mocked_get_latch.return_value = {'pending': True}
rv = client.post( rv = client.post(
'jobs/update?force=no', 'orig-jobs/update?force=no',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 503 assert rv.status_code == 503
...@@ -89,7 +89,7 @@ def test_job_update_pending(client, mocker): ...@@ -89,7 +89,7 @@ def test_job_update_pending(client, mocker):
mocked_get_latch.return_value = {'pending': True} mocked_get_latch.return_value = {'pending': True}
rv = client.post( rv = client.post(
'jobs/update', 'orig-jobs/update',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 503 assert rv.status_code == 503
...@@ -108,7 +108,7 @@ def test_reload_router_config(client, mocker): ...@@ -108,7 +108,7 @@ def test_reload_router_config(client, mocker):
delay_result.return_value = MockedAsyncResult('bogus task id') delay_result.return_value = MockedAsyncResult('bogus task id')
rv = client.post( rv = client.post(
'jobs/reload-router-config/ignored###123', 'orig-jobs/reload-router-config/ignored###123',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
refresh_task_response = json.loads(rv.data.decode('utf-8')) refresh_task_response = json.loads(rv.data.decode('utf-8'))
...@@ -127,7 +127,7 @@ def test_check_update_status(client, mocker): ...@@ -127,7 +127,7 @@ def test_check_update_status(client, mocker):
MockedAsyncResult.result = {'absab': 1, 'def': 'aaabbb'} MockedAsyncResult.result = {'absab': 1, 'def': 'aaabbb'}
rv = client.post( rv = client.post(
'jobs/check-update-status', 'orig-jobs/check-update-status',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8')) result = json.loads(rv.data.decode('utf-8'))
...@@ -147,7 +147,7 @@ def test_check_update_status_404(client): ...@@ -147,7 +147,7 @@ def test_check_update_status_404(client):
db.pop('classifier-cache:update-task-id', None) db.pop('classifier-cache:update-task-id', None)
rv = client.post( rv = client.post(
'jobs/check-update-status', 'orig-jobs/check-update-status',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 404 assert rv.status_code == 404
...@@ -159,7 +159,7 @@ def test_check_task_status_success(client, mocker): ...@@ -159,7 +159,7 @@ def test_check_task_status_success(client, mocker):
MockedAsyncResult.result = {'abc': 1, 'def': 'aaabbb'} MockedAsyncResult.result = {'abc': 1, 'def': 'aaabbb'}
rv = client.post( rv = client.post(
'jobs/check-task-status/abc', 'orig-jobs/check-task-status/abc',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8')) result = json.loads(rv.data.decode('utf-8'))
...@@ -180,7 +180,7 @@ def test_check_task_status_custom_status(client, mocker): ...@@ -180,7 +180,7 @@ def test_check_task_status_custom_status(client, mocker):
MockedAsyncResult.result = None MockedAsyncResult.result = None
rv = client.post( rv = client.post(
'jobs/check-task-status/xyz', 'orig-jobs/check-task-status/xyz',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8')) result = json.loads(rv.data.decode('utf-8'))
...@@ -200,7 +200,7 @@ def test_check_task_status_exception(client, mocker): ...@@ -200,7 +200,7 @@ def test_check_task_status_exception(client, mocker):
MockedAsyncResult.result = AssertionError('test error message') MockedAsyncResult.result = AssertionError('test error message')
rv = client.post( rv = client.post(
'jobs/check-task-status/123-xyz.ABC', 'orig-jobs/check-task-status/123-xyz.ABC',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8')) result = json.loads(rv.data.decode('utf-8'))
...@@ -332,7 +332,7 @@ def test_job_log(client): ...@@ -332,7 +332,7 @@ def test_job_log(client):
db[k] = json.dumps(v) db[k] = json.dumps(v)
rv = client.post( rv = client.post(
'jobs/log', 'orig-jobs/log',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
result = json.loads(rv.data.decode('utf-8')) result = json.loads(rv.data.decode('utf-8'))
......
...@@ -11,7 +11,7 @@ DEFAULT_REQUEST_HEADERS = { ...@@ -11,7 +11,7 @@ DEFAULT_REQUEST_HEADERS = {
def test_public_routers(client): def test_public_routers(client):
rv = client.get( rv = client.get(
'/lg/routers/public', '/orig-lg/routers/public',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.is_json assert rv.is_json
...@@ -25,7 +25,7 @@ def test_public_routers(client): ...@@ -25,7 +25,7 @@ def test_public_routers(client):
def test_internal_routers(client): def test_internal_routers(client):
rv = client.get( rv = client.get(
'/lg/routers/all', '/orig-lg/routers/all',
headers=DEFAULT_REQUEST_HEADERS) headers=DEFAULT_REQUEST_HEADERS)
assert rv.status_code == 200 assert rv.status_code == 200
assert rv.is_json assert rv.is_json
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment