From 69d073db1f66abd7a0a6137aebb762951dbcff31 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 9 Feb 2021 15:41:32 +0000 Subject: [PATCH] added test for port_id_services --- test/test_ims_data.py | 80 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/test/test_ims_data.py b/test/test_ims_data.py index bf37692f..171c5750 100644 --- a/test/test_ims_data.py +++ b/test/test_ims_data.py @@ -5,7 +5,85 @@ from inventory_provider.db.ims import InventoryStatus from inventory_provider.db.ims_data import lookup_lg_routers, \ otrs_get_customer_company_rows, \ otrs_get_customer_users_rows, get_node_locations, IMS_OPSDB_STATUS_MAP, \ - get_fibre_info + get_fibre_info, get_port_id_services + + +def test_get_port_id_services(mocker): + called = False + + def _se(a, b, c, step_count): + nonlocal called + if called: + return {} + else: + called = True + with open('test/data/ims_port_id_services_data.json') as data: + return json.load(data) + + mocker.patch.object( + inventory_provider.db.ims.IMS, + 'get_filtered_entities', + side_effect=_se + ) + + ds = inventory_provider.db.ims.IMS( + 'dummy_base', 'dummy_username', 'dummy_password') + res = list(get_port_id_services(ds)) + + # this is the number of different product types that are considered service + # and speed types that that cover circuit types that have relevant circuits + # and ethernet product type as other relevant circuits also need tracking + assert ds.get_filtered_entities.call_count == 20 + predicted = [ + { + 'id': 663060, + 'name': 'RENATER_AP2', + 'status': 'operational', + 'circuit_type': 'service', + 'service_type': 'GEANT IP', + 'project': 'RENATER', + 'port_a_id': 224507, + }, + { + 'id': 663104, + 'name': 'ULAKBIM_AP2_IAS', + 'status': 'operational', + 'circuit_type': 'service', + 'service_type': 'GEANT PEERING', + 'project': 'ULAKBIM', + 'port_a_id': 224464, + }, + { + 'id': 679324, + 'name': 'AMSTERDAM-LONDON-100GBE-001(ETH)', + 'status': 'operational', + 'circuit_type': 'circuit', + 'service_type': 'ETHERNET', + 'project': 'ETH', + 'port_a_id': 6423107, + 'port_b_id': 6419340, + }, + { + 'id': 679324, + 'name': 'AMSTERDAM-LONDON-100GBE-001(ETH)', + 'status': 'operational', + 'circuit_type': 'circuit', + 'service_type': 'ETHERNET', + 'project': 'ETH', + 'port_a_id': 6419340, + 'port_b_id': 6423107, + }, + { + 'id': 679324, + 'name': 'AMSTERDAM-LONDON-100GBE-001(ETH)', + 'status': 'operational', + 'circuit_type': 'circuit', + 'service_type': 'ETHERNET', + 'project': 'ETH', + 'port_a_id': 6423111 + } + ] + assert res == predicted def test_get_fibre_info(mocker): -- GitLab