From 669e787c2e701dd1ad1f2ff648cca5bdd28c810c Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Mon, 8 Feb 2021 13:12:38 +0000
Subject: [PATCH] updated endpoints for original opsdb based tests

---
 test/per_router/test_data_routes.py |  2 +-
 test/test_classifier_routes.py      | 38 +++++++++++++++++++----------
 test/test_general_data_routes.py    |  8 +++---
 test/test_ims_data.py               | 10 ++++----
 test/test_infinera_classifier.py    | 20 ---------------
 test/test_job_routes.py             | 22 ++++++++---------
 test/test_lg_routes.py              |  4 +--
 7 files changed, 48 insertions(+), 56 deletions(-)
 delete mode 100644 test/test_infinera_classifier.py

diff --git a/test/per_router/test_data_routes.py b/test/per_router/test_data_routes.py
index b1fbdbe0..1216edc6 100644
--- a/test/per_router/test_data_routes.py
+++ b/test/per_router/test_data_routes.py
@@ -39,7 +39,7 @@ def test_router_interfaces(router, client):
     }
 
     rv = client.post(
-        "/data/interfaces/" + router,
+        "/orig-data/interfaces/" + router,
         headers=DEFAULT_REQUEST_HEADERS)
 
     assert rv.status_code == 200
diff --git a/test/test_classifier_routes.py b/test/test_classifier_routes.py
index 83b358bf..b009ca29 100644
--- a/test/test_classifier_routes.py
+++ b/test/test_classifier_routes.py
@@ -4,7 +4,8 @@ import jsonschema
 import pytest
 
 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 = {
     "Content-type": "application/json",
@@ -14,7 +15,7 @@ DEFAULT_REQUEST_HEADERS = {
 
 def test_juniper_link_info(client):
     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)
     assert rv.status_code == 200
     assert rv.is_json
@@ -24,7 +25,7 @@ def test_juniper_link_info(client):
 
 def test_juniper_link_info_not_found(client):
     rv = client.get(
-        '/classifier/juniper-link-info/'
+        '/orig-classifier/juniper-link-info/'
         'mx1.ams.nl.geant.net/unknown-interface-name',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
@@ -51,7 +52,7 @@ def test_juniper_link_info_not_found(client):
 
 def test_juniper_link_unknown_router(client):
     rv = client.get(
-        '/classifier/juniper-link-info/'
+        '/orig-classifier/juniper-link-info/'
         'unknown-router/unknown-interface-name',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
@@ -91,7 +92,7 @@ def test_peer_info(
         client, peer_address, expected_response_keys):
 
     rv = client.get(
-        '/classifier/peer-info/%s' % peer_address,
+        '/orig-classifier/peer-info/%s' % peer_address,
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     assert rv.is_json
@@ -103,14 +104,14 @@ def test_peer_info(
 
 def test_peer_invalid_address(client):
     rv = client.get(
-        '/classifier/peer-info/1.2.3.4.5',
+        '/orig-classifier/peer-info/1.2.3.4.5',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 422
 
 
 def test_peer_not_found(client):
     rv = client.get(
-        '/classifier/peer-info/1.2.3.4',
+        '/orig-classifier/peer-info/1.2.3.4',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     response_data = json.loads(rv.data.decode('utf-8'))
@@ -163,7 +164,7 @@ def test_coriant_info(
         })
 
     rv = client.get(
-        '/classifier/coriant-info/{equipment}/{entity}'.format(
+        '/orig-classifier/coriant-info/{equipment}/{entity}'.format(
             equipment=equipment,
             entity=entity_name),
         headers=DEFAULT_REQUEST_HEADERS)
@@ -214,7 +215,7 @@ def test_coriant_info_not_found(client, mocker):
         lambda a, b, c, d: None)
 
     rv = client.get(
-        '/classifier/coriant-info/aaa/unparseableentitystring',
+        '/orig-classifier/coriant-info/aaa/unparseableentitystring',
         headers=DEFAULT_REQUEST_HEADERS)
 
     assert rv.status_code == 404
@@ -222,19 +223,19 @@ def test_coriant_info_not_found(client, mocker):
 
 def test_infinera_unparseable_fiberlink(client):
     rv = client.get(
-        '/classifier/infinera-fiberlink-info/unparseableentitystring/aaa',
+        '/orig-classifier/infinera-fiberlink-info/unparseableentitystring/aaa',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 422
 
     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)
     assert rv.status_code == 422
 
 
 def test_infinera_fiberlink_not_found(client):
     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',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 404
@@ -254,7 +255,7 @@ def test_infinera_fiberlink(client, mocker):
         'inventory_provider.routes.classifier.get_top_level_services')
     mocked_tls.return_value = {'a': 'A'}
     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',
         headers=DEFAULT_REQUEST_HEADERS)
     mg.assert_any_call(
@@ -286,3 +287,14 @@ def test_infinera_fiberlink(client, mocker):
 
     assert rv.status_code == 200
     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)
diff --git a/test/test_general_data_routes.py b/test/test_general_data_routes.py
index a618f8fb..f0a1ecfa 100644
--- a/test/test_general_data_routes.py
+++ b/test/test_general_data_routes.py
@@ -16,7 +16,7 @@ def test_get_routers(client):
     }
 
     rv = client.post(
-        "data/routers",
+        "orig-data/routers",
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     response = json.loads(rv.data.decode("utf-8"))
@@ -45,7 +45,7 @@ def test_pop_info(client, mocker):
         lambda c, e: {'C': c, 'E': e})
 
     rv = client.get(
-        '/data/pop/{E}'.format(**expected_pop_info),
+        '/orig-data/pop/{E}'.format(**expected_pop_info),
         headers=DEFAULT_REQUEST_HEADERS)
 
     assert rv.status_code == 200
@@ -71,7 +71,7 @@ def test_pop_not_found(client, mocker):
         lambda a, b: None)
 
     rv = client.get(
-        '/data/pop/aabbcc',
+        '/orig-data/pop/aabbcc',
         headers=DEFAULT_REQUEST_HEADERS)
 
     assert rv.status_code == 404
@@ -107,7 +107,7 @@ def test_router_interfaces_all(client):
     }
 
     rv = client.post(
-        '/data/interfaces',
+        '/orig-data/interfaces',
         headers=DEFAULT_REQUEST_HEADERS)
 
     assert rv.status_code == 200
diff --git a/test/test_ims_data.py b/test/test_ims_data.py
index 6bc3018b..bf37692f 100644
--- a/test/test_ims_data.py
+++ b/test/test_ims_data.py
@@ -37,7 +37,7 @@ def test_get_fibre_info(mocker):
                 "circuit_id": 659616,
                 "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
                 "df_route_id": 662153,
-                "df_status": "Operational",
+                "df_status": "operational",
                 "ne": "BUD01-DTNX10-1-3"
             }
         ],
@@ -46,7 +46,7 @@ def test_get_fibre_info(mocker):
                 "circuit_id": 659617,
                 "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
                 "df_route_id": 662153,
-                "df_status": "Operational",
+                "df_status": "operational",
                 "ne": "KOM-OLA1-1"
             }
         ],
@@ -55,7 +55,7 @@ def test_get_fibre_info(mocker):
                 "circuit_id": 659616,
                 "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
                 "df_route_id": 662153,
-                "df_status": "Operational",
+                "df_status": "operational",
                 "ne": "SZE-OLA1-1"
             }
         ],
@@ -64,7 +64,7 @@ def test_get_fibre_info(mocker):
                 "circuit_id": 659617,
                 "df_route": "BUDAPEST-ZAGREB-OS160-001(UNKNOWN)",
                 "df_route_id": 662153,
-                "df_status": "Operational",
+                "df_status": "operational",
                 "ne": "ZAG01-DTNX10-1-2"
             }
         ]
@@ -101,7 +101,7 @@ def test_lookup_lg_routers(mocker):
 
     ds.get_filtered_entities.assert_called_once_with(
         'EquipmentDefinition',
-        'Name like mx',
+        'Name like MX',
         inventory_provider.db.ims.EQUIP_DEF_PROPERTIES['Nodes'])
 
     assert ds.get_entity_by_id.call_count == 35
diff --git a/test/test_infinera_classifier.py b/test/test_infinera_classifier.py
deleted file mode 100644
index c4d2488f..00000000
--- a/test/test_infinera_classifier.py
+++ /dev/null
@@ -1,20 +0,0 @@
-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)
diff --git a/test/test_job_routes.py b/test/test_job_routes.py
index f3a4df17..4c7e34db 100644
--- a/test/test_job_routes.py
+++ b/test/test_job_routes.py
@@ -29,7 +29,7 @@ def test_job_update_all(client, mocker):
     launch_refresh_cache_all.return_value = expected_task_id
 
     rv = client.post(
-        'jobs/update',
+        'orig-jobs/update',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     refresh_task_response = json.loads(rv.data.decode('utf-8'))
@@ -52,7 +52,7 @@ def test_job_update_force_pending(client, mocker):
     mocked_get_latch.return_value = {'pending': True}
 
     rv = client.post(
-        'jobs/update?force=true',
+        'orig-jobs/update?force=true',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     refresh_task_response = json.loads(rv.data.decode('utf-8'))
@@ -72,7 +72,7 @@ def test_job_update_pending_force_false(client, mocker):
     mocked_get_latch.return_value = {'pending': True}
 
     rv = client.post(
-        'jobs/update?force=no',
+        'orig-jobs/update?force=no',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 503
 
@@ -89,7 +89,7 @@ def test_job_update_pending(client, mocker):
     mocked_get_latch.return_value = {'pending': True}
 
     rv = client.post(
-        'jobs/update',
+        'orig-jobs/update',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 503
 
@@ -108,7 +108,7 @@ def test_reload_router_config(client, mocker):
     delay_result.return_value = MockedAsyncResult('bogus task id')
 
     rv = client.post(
-        'jobs/reload-router-config/ignored###123',
+        'orig-jobs/reload-router-config/ignored###123',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     refresh_task_response = json.loads(rv.data.decode('utf-8'))
@@ -127,7 +127,7 @@ def test_check_update_status(client, mocker):
     MockedAsyncResult.result = {'absab': 1, 'def': 'aaabbb'}
 
     rv = client.post(
-        'jobs/check-update-status',
+        'orig-jobs/check-update-status',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
@@ -147,7 +147,7 @@ def test_check_update_status_404(client):
     db.pop('classifier-cache:update-task-id', None)
 
     rv = client.post(
-        'jobs/check-update-status',
+        'orig-jobs/check-update-status',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 404
 
@@ -159,7 +159,7 @@ def test_check_task_status_success(client, mocker):
     MockedAsyncResult.result = {'abc': 1, 'def': 'aaabbb'}
 
     rv = client.post(
-        'jobs/check-task-status/abc',
+        'orig-jobs/check-task-status/abc',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
@@ -180,7 +180,7 @@ def test_check_task_status_custom_status(client, mocker):
     MockedAsyncResult.result = None
 
     rv = client.post(
-        'jobs/check-task-status/xyz',
+        'orig-jobs/check-task-status/xyz',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
@@ -200,7 +200,7 @@ def test_check_task_status_exception(client, mocker):
     MockedAsyncResult.result = AssertionError('test error message')
 
     rv = client.post(
-        'jobs/check-task-status/123-xyz.ABC',
+        'orig-jobs/check-task-status/123-xyz.ABC',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
@@ -332,7 +332,7 @@ def test_job_log(client):
         db[k] = json.dumps(v)
 
     rv = client.post(
-        'jobs/log',
+        'orig-jobs/log',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     result = json.loads(rv.data.decode('utf-8'))
diff --git a/test/test_lg_routes.py b/test/test_lg_routes.py
index add33c4b..08bfe835 100644
--- a/test/test_lg_routes.py
+++ b/test/test_lg_routes.py
@@ -11,7 +11,7 @@ DEFAULT_REQUEST_HEADERS = {
 
 def test_public_routers(client):
     rv = client.get(
-        '/lg/routers/public',
+        '/orig-lg/routers/public',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     assert rv.is_json
@@ -25,7 +25,7 @@ def test_public_routers(client):
 
 def test_internal_routers(client):
     rv = client.get(
-        '/lg/routers/all',
+        '/orig-lg/routers/all',
         headers=DEFAULT_REQUEST_HEADERS)
     assert rv.status_code == 200
     assert rv.is_json
-- 
GitLab