diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index 77614dc33700cdf8e26c61544c4c972d6214934c..c0fcc045ce06ff4e1779224bb00b66e5e4d5b701 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -73,19 +73,6 @@ def get_fibre_info(ds: IMS): def get_port_id_services(ds: IMS): - # this is the only place that speeds are used, - # products are used else where to define services, so a relevant list of - # products has been moved to the ims module as IMS_SERVICE_NAMES - # The products here are all the products we need to be able to build map - # ports to services - products = copy(IMS_SERVICE_NAMES) - products.add('ETHERNET') - speeds = { - 'L3VPN', - 'LAG', - 'FIBRE_ROUTE', - # 'BGP', - } circuit_nav_props = [ ims.CIRCUIT_PROPERTIES['Customer'], ims.CIRCUIT_PROPERTIES['Speed'], @@ -95,26 +82,16 @@ def get_port_id_services(ds: IMS): ] def _get_circuits(): - for st in products: - for c in ds.get_filtered_entities( - 'Circuit', - f'product.name == "{st}"', - circuit_nav_props, - step_count=2000): - if c['product']['name'] in IMS_SERVICE_NAMES: - c['circuit_type'] = 'service' - else: - c['circuit_type'] = 'circuit' - yield c - for spd in speeds: - for c in ds.get_filtered_entities( - 'Circuit', - f'speed.name == "{spd}"', - circuit_nav_props, - step_count=2000): + for c in ds.get_all_entities( + 'Circuit', + circuit_nav_props, + step_count=2000): + if c['product']['name'] in IMS_SERVICE_NAMES: + c['circuit_type'] = 'service' + else: c['circuit_type'] = 'circuit' - yield c + yield c circuits = _get_circuits() diff --git a/test/test_ims_data.py b/test/test_ims_data.py index 29e67e0ccfa57c91dc16153610514ba5b350adbf..a774ad3839d874abd27939e2ccabf22a9ce47911 100644 --- a/test/test_ims_data.py +++ b/test/test_ims_data.py @@ -101,21 +101,13 @@ def test_get_port_details(mocker): 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) + with open('test/data/ims_port_id_services_data.json') as data: + d = json.load(data) mocker.patch.object( inventory_provider.db.ims.IMS, - 'get_filtered_entities', - side_effect=_se + 'get_all_entities', + side_effect=[d] ) ds = inventory_provider.db.ims.IMS( @@ -125,7 +117,7 @@ def test_get_port_id_services(mocker): # 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 + assert ds.get_all_entities.call_count == 1 predicted = [ { 'id': 663060,