Skip to content
Snippets Groups Projects
Commit 6633e075 authored by Saket Agrahari's avatar Saket Agrahari
Browse files

Merge branch 'feature/DBOARD3-676' into 'develop'

Adding testing for mic

See merge request !26
parents 99dd0408 339417dc
No related branches found
No related tags found
1 merge request!26Adding testing for mic
......@@ -60,13 +60,12 @@ NODE_LOCATION_SCHEMA = {
'properties': {
'equipment-name': {'type': 'string'},
'status': {'type': 'string'},
'pop': {'$ref': '#/definitions/pop-location'}
'pop': {'$ref': '#/definitions/pop-location'}
},
'required': ['equipment-name', 'status', 'pop'],
'additionalProperties': False
}
SITE_LOCATION_SCHEMA = {
'$schema': 'https://json-schema.org/draft-07/schema#',
**_POP_LOCATION_SCHEMA_STRUCT
......@@ -117,12 +116,13 @@ def get_monitored_circuit_ids(ds: IMS):
@log_entry_and_exit
def get_ids_and_sids(ds: IMS):
for sid_circuit in ds.get_filtered_entities(
'ExtraFieldValue',
'extrafieldid == 3209 | value <> ""',
step_count=10000
'ExtraFieldValue',
'extrafieldid == 3209 | value <> ""',
step_count=10000
):
yield sid_circuit['objectid'], sid_circuit['value']
@log_entry_and_exit
def get_ids_and_third_party_ids(ds: IMS):
for circuit in ds.get_filtered_entities(
......@@ -132,6 +132,7 @@ def get_ids_and_third_party_ids(ds: IMS):
):
yield circuit['objectid'], circuit['value']
@log_entry_and_exit
def get_service_types(ds: IMS):
for d in ds.get_filtered_entities(
......@@ -142,13 +143,12 @@ def get_service_types(ds: IMS):
@log_entry_and_exit
def get_customer_tts_contacts(ds: IMS):
customer_contacts = defaultdict(set)
for x in ds.get_filtered_entities(
'customerrelatedcontact',
"contact.troubleticketMail != ''",
CUSTOMER_RELATED_CONTACT_PROPERTIES['Contact']
'customerrelatedcontact',
"contact.troubleticketMail != ''",
CUSTOMER_RELATED_CONTACT_PROPERTIES['Contact']
):
customer_contacts[x['customerid']].add(
x['contact']['troubleticketmail'])
......@@ -158,13 +158,12 @@ def get_customer_tts_contacts(ds: IMS):
@log_entry_and_exit
def get_customer_planned_work_contacts(ds: IMS):
customer_contacts = defaultdict(set)
for x in ds.get_filtered_entities(
'customerrelatedcontact',
"contact.PlannedworkMail != ''",
CUSTOMER_RELATED_CONTACT_PROPERTIES['Contact']
'customerrelatedcontact',
"contact.PlannedworkMail != ''",
CUSTOMER_RELATED_CONTACT_PROPERTIES['Contact']
):
customer_contacts[x['customerid']].add(
x['contact']['plannedworkmail'])
......@@ -174,11 +173,10 @@ def get_customer_planned_work_contacts(ds: IMS):
@log_entry_and_exit
def get_circuit_related_customers(ds: IMS):
return_value = defaultdict(list)
for ccr in ds.get_filtered_entities(
'CircuitCustomerRelation',
'circuit.inventoryStatusId== 3',
'CircuitCustomerRelation',
'circuit.inventoryStatusId== 3',
ims.CIRCUIT_CUSTOMER_RELATION['Customer']):
return_value[ccr['circuitid']].append(
{
......@@ -481,13 +479,13 @@ def get_site_locations(ds: IMS):
has_geo_data = bool(site.get('longitude') and site.get('latitude'))
if abbreviation and has_geo_data:
yield site['name'], {
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
@log_entry_and_exit
......@@ -616,14 +614,14 @@ def lookup_lg_routers(ds: IMS):
'INTERNAL'
if site['name'] in INTERNAL_POP_NAMES
else 'CORE',
'pop': {
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'country code': city['country']['abbreviation'],
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
'pop': {
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'country code': city['country']['abbreviation'],
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
}
yield eq
......@@ -631,8 +629,7 @@ def lookup_lg_routers(ds: IMS):
@log_entry_and_exit
def lookup_geant_nodes(ds: IMS):
return (n["name"]for n in ds.get_filtered_entities(
return (n["name"] for n in ds.get_filtered_entities(
'Node',
'customer.Name == "GEANT"',
ims.EQUIP_DEF_PROPERTIES['Nodes']))
......@@ -52,12 +52,9 @@ ALL_DATA_SCHEMA = {
"type": "array",
"items": {"type": "string"}
},
"third_party_id": {
"type": "array",
"items": {"type": "string"}
}
"third_party_id": {"type": "string"}
},
"required": ["id", "sid", "status", "name", "service_type", "contacts", "planned_work_contacts","third_party_id"], # noqa E501
"required": ["id", "sid", "status", "name", "service_type", "contacts", "planned_work_contacts"], # noqa E501
"additionalProperties": False
}
}
......
......@@ -89,6 +89,14 @@ def test_extract_ims_data(mocker):
(111113, 'SID-03')
])
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.get_ids_and_third_party_ids',
return_value=(x for x in [
(111111, 'TPID-01'),
(111112, 'TPID-02'),
(111113, 'TPID-03')
])
)
mocker.patch(
'inventory_provider.tasks.worker.ims_data.lookup_geant_nodes',
return_value=[]
......@@ -149,6 +157,11 @@ def test_extract_ims_data(mocker):
111112: 'SID-02',
111113: 'SID-03'
}
assert res['circuit_ids_third_party_ids'] == {
111111: 'TPID-01',
111112: 'TPID-02',
111113: 'TPID-03'
}
def test_transform_ims_data():
......@@ -379,6 +392,11 @@ def test_transform_ims_data():
"circ_id_2": 'SID-02',
"circ_id_3": 'SID-03'
}
circuit_ids_third_party_ids = {
"sub_circuit_2": 'TPID-01',
"circ_id_2": 'TPID-02',
"circ_id_3": 'TPID-03'
}
flexils_data = {
702203: [
{
......@@ -410,6 +428,7 @@ def test_transform_ims_data():
"port_id_details": port_id_details,
"port_id_services": port_id_services,
"circuit_ids_sids": circuit_ids_and_sids,
"circuit_ids_third_party_ids": circuit_ids_third_party_ids,
"geant_nodes": ["eq_b"],
"flexils_data": flexils_data,
"customers": customers,
......@@ -538,7 +557,8 @@ def test_persist_ims_data(mocker, data_config, mocked_redis):
"sid": "SID-01",
"service_type": "type a",
"contacts": ["c1", "c2"],
"planned_work_contacts": ["c1"]
"planned_work_contacts": ["c1"],
"third_party_id": "I2-S13168 - RTSW.NEWY32AOA.NET.INTERNET2.EDU"
}
],
},
......
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