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

added test for port_id_services

parent aeb9db17
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,85 @@ from inventory_provider.db.ims import InventoryStatus ...@@ -5,7 +5,85 @@ from inventory_provider.db.ims import InventoryStatus
from inventory_provider.db.ims_data import lookup_lg_routers, \ from inventory_provider.db.ims_data import lookup_lg_routers, \
otrs_get_customer_company_rows, \ otrs_get_customer_company_rows, \
otrs_get_customer_users_rows, get_node_locations, IMS_OPSDB_STATUS_MAP, \ 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): def test_get_fibre_info(mocker):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment