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

added all circuits to cache

parent be0352ba
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment