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

updated tests

parent 6326324f
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ from inventory_provider.db.ims_data import lookup_lg_routers, \
get_node_locations, IMS_OPSDB_STATUS_MAP, \
get_port_id_services, get_port_details, \
get_circuit_hierarchy, get_ids_and_sids, NODE_LOCATION_SCHEMA, \
get_flex_ils_entities
get_flexils_by_circuitid
def _json_test_data(filename):
......@@ -388,7 +388,7 @@ def test_get_circuit_ids_and_sids(mocker):
assert res == expected_response
def test_get_flex_ils_entities(mocker):
def test_get_flexils_by_circuit_id(mocker):
ims = mocker.patch('inventory_provider.db.ims.IMS')
ims.return_value.get_all_entities.return_value = \
[
......@@ -427,22 +427,22 @@ def test_get_flex_ils_entities(mocker):
"customproperties": {}
}
]
expected_result = [
{
'circuit_id': 702203,
'node_name': 'CAM01-MTC6-3',
'port_name': 'A-1-S1',
'full_port_name': '1-A-1-S1-1'
},
{
'circuit_id': 702203,
'node_name': 'CAM01-MTC6-3',
'port_name': 'A-1-L1',
'full_port_name': '1-A-1-L1-1'
}
]
expected_result = {
702203: [
{
'node_name': 'CAM01-MTC6-3',
'full_port_name': '1-A-1-S1-1',
'key': 'CAM01-MTC6-3:1-A-1-S1-1'
},
{
'node_name': 'CAM01-MTC6-3',
'full_port_name': '1-A-1-L1-1',
'key': 'CAM01-MTC6-3:1-A-1-L1-1'
}
]
}
ds = inventory_provider.db.ims.IMS(
'dummy_base', 'dummy_username', 'dummy_password')
res = list(get_flex_ils_entities(ds))
res = get_flexils_by_circuitid(ds)
assert res == expected_result
......@@ -81,6 +81,10 @@ def test_extract_ims_data(mocker):
'inventory_provider.tasks.worker.ims_data.lookup_geant_nodes',
return_value=[]
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.get_flexils_by_circuitid',
return_value={}
)
res = extract_ims_data()
assert res['locations'] == {'loc_a': 'LOC A', 'loc_b': 'LOC B'}
assert res['lg_routers'] == ['lg router 1', 'lg router 2']
......@@ -321,6 +325,18 @@ def test_transform_ims_data():
"carrier-circuits": ["sub_circuit_1"],
"sub-circuits": [],
"customerid": "cu_1",
},
702203: {
"id": 702203,
"name": "FLEX ILS CIRCUIT",
"status": "operational",
"circuit-type": "circuit",
"product": "ethernet",
"speed": "not fiber route",
"project": "customer_1",
"carrier-circuits": ["circ_id_1"],
"sub-circuits": ["sub_circuit_2"],
"customerid": "cu_1",
}
}
......@@ -329,6 +345,20 @@ def test_transform_ims_data():
"circ_id_2": 'SID-02',
"circ_id_3": 'SID-03'
}
flexils_data = {
702203: [
{
'node_name': 'CAM01-MTC6-3',
'full_port_name': '1-A-1-S1-1',
'key': 'CAM01-MTC6-3:1-A-1-S1-1'
},
{
'node_name': 'CAM01-MTC6-3',
'full_port_name': '1-A-1-L1-1',
'key': 'CAM01-MTC6-3:1-A-1-L1-1'
}
]
}
data = {
"locations": locations,
"customer_contacts": customer_contacts,
......@@ -339,9 +369,12 @@ def test_transform_ims_data():
"port_id_details": port_id_details,
"port_id_services": port_id_services,
"circuit_ids_sids": circuit_ids_and_sids,
"geant_nodes": ["eq_b"]
"geant_nodes": ["eq_b"],
"flexils_data": flexils_data
}
orig_port_id_services_len = len(port_id_services.keys())
res = transform_ims_data(data)
assert len(port_id_services) == orig_port_id_services_len + 2
pop_nodes_res = {
"pop_loc_a": ["eq_a"],
"pop_loc_b": ["eq_b"],
......@@ -352,7 +385,13 @@ def test_transform_ims_data():
assert v == res["pop_nodes"][k]
ifs = res["interface_services"]
assert list(ifs.keys()) == [
"eq_a:if_a", "eq_b:if_b", "eq_a:if_c", "eq_b:if_c"]
"eq_a:if_a",
"eq_b:if_b",
"eq_a:if_c",
"eq_b:if_c",
"CAM01-MTC6-3:1-A-1-S1-1",
"CAM01-MTC6-3:1-A-1-L1-1"
]
for v in ifs.values():
assert len(v) == 1
assert len(v[0]["related-services"]) == 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment