Skip to content
Snippets Groups Projects
Commit bc844858 authored by Erik Reid's avatar Erik Reid
Browse files

Merge branch 'develop' of...

Merge branch 'develop' of gitlab.geant.net:live-projects/dashboardv3/inventory-provider into develop
parents 82701463 91346358
No related branches found
No related tags found
No related merge requests found
......@@ -115,7 +115,7 @@ class IMS(object):
auth=(username, password))
response.raise_for_status()
cls.bearer_token_init_time = re_init_time
cls.bearer_token = response.json()
cls.bearer_token = response.text
def _get_entity(
self,
......@@ -156,16 +156,29 @@ class IMS(object):
return False
def _convert_keys(source):
if isinstance(source, list):
return [_convert_keys(x) for x in source]
elif isinstance(source, dict):
new = {}
for k, v in source.items():
if isinstance(v, (dict, list)):
v = _convert_keys(v)
new[k.lower()] = v
return new
return source
while True:
response = requests.get(
url,
headers={'Authorization': self.bearer_token},
headers={'Authorization': f'Bearer {self.bearer_token}'},
params=params)
if _is_invalid_login_state(response):
IMS._init_bearer_token(self.username, self.password)
else:
response.raise_for_status()
return_value = response.json()
orig = response.json()
return_value = _convert_keys(orig)
if use_cache:
IMS.cache[cache_key] = return_value
......
......@@ -122,13 +122,13 @@ def otrs_get_customer_company_rows(ds):
'comments']
all_cus_comps = set()
for customer in ds.get_all_entities('Customer'):
all_cus_comps.add(customer['Name'])
yield [customer['Name'].replace(' ', ''), customer['Name'],
all_cus_comps.add(customer['name'])
yield [customer['name'].replace(' ', ''), customer['name'],
'', '', '', '', '', '']
for vendor in ds.get_all_entities('Vendor'):
if vendor['Name'] not in all_cus_comps:
all_cus_comps.add(vendor['Name'])
yield [vendor['Name'].replace(' ', ''), vendor['Name'],
if vendor['name'] not in all_cus_comps:
all_cus_comps.add(vendor['name'])
yield [vendor['name'].replace(' ', ''), vendor['name'],
'', '', '', '', '', '']
......@@ -142,7 +142,7 @@ def _is_valid_customer(cus):
def otrs_get_customer_contacts(ds):
def _get_customer_id2(t):
if t['Id'] == 3 or t['Name'] == 'EU NREN':
if t['id'] == 3 or t['name'] == 'EU NREN':
return 'OTRS-GEANT-NREN'
return ''
......@@ -153,21 +153,21 @@ def otrs_get_customer_contacts(ds):
ims.CUSTOMER_PROPERTIES['CustomerType']
]):
if customer['CustomerRelatedContacts']:
if customer['customerrelatedcontacts']:
for contact in customer['CustomerRelatedContacts']:
for contact in customer['customerrelatedcontacts']:
t_customer_user = OrderedDict({
'email': contact['Contact']['Mail'],
'username': contact['Contact']['Mail'], # TODO if tal_id is going to be present use that # noqa
'customer_id': customer['Name'].replace(' ', ''),
'email': contact['contact']['mail'],
'username': contact['contact']['mail'], # TODO if tal_id is going to be present use that # noqa
'customer_id': customer['name'].replace(' ', ''),
'customer_id_2':
_get_customer_id2(customer['CustomerType']),
_get_customer_id2(customer['customertype']),
'title': '',
'firstname': contact['Contact']['Name'],
'firstname': contact['contact']['name'],
'lastname':
' '.join(filter(None, [
contact['Contact']['InFix'],
contact['Contact']['LastName']
contact['contact']['infix'],
contact['contact']['lastname']
])),
'phone': '',
'fax': '',
......@@ -193,16 +193,16 @@ def otrs_get_vendor_contacts(ds):
ims.VENDOR_RELATED_CONTACT_PROPERTIES['Contact']
]):
t_customer_user = OrderedDict({
'email': vrc['Contact']['Mail'],
'username': vrc['Contact']['Mail'], # TODO if tal_id is going to be present use that # noqa
'customer_id': vrc['Vendor']['Name'].replace(' ', ''),
'email': vrc['contact']['mail'],
'username': vrc['contact']['mail'], # TODO if tal_id is going to be present use that # noqa
'customer_id': vrc['vendor']['name'].replace(' ', ''),
'customer_id_2': '',
'title': '',
'firstname': vrc['Contact']['Name'],
'firstname': vrc['contact']['name'],
'lastname':
' '.join(filter(None, [
vrc['Contact']['InFix'],
vrc['Contact']['LastName']
vrc['contact']['infix'],
vrc['contact']['lastname']
])),
'phone': '',
'fax': '',
......@@ -263,7 +263,6 @@ def otrs_get_customer_users_rows(ds, return_duplicates=False):
if duplicate_emails:
logger.info('Duplicate emails found in OTRS customer-user export: '
f'{duplicate_emails} - attempting to weed')
# weeded = []
for email in duplicate_emails:
weeded = weed_duplicates(cus_by_email.pop(email))
if len(weeded) == 1:
......@@ -275,8 +274,6 @@ def otrs_get_customer_users_rows(ds, return_duplicates=False):
)
if remaining_duplicates:
# need guidance what to do if this occurs, should we pick the first
# one for each, or ignore them completely? Ignoring them for now
logger.error('Duplicate emails remain after weeding, '
f'{"including" if return_duplicates else "excluding"}'
' duplicates in returned data: ')
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.44",
version="0.45",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......
{
"Customer": [
{
"Id": 57284,
"ParentCustomerId": null,
"Name": "DUMMY 1",
"FullName": "DUMMY 1",
"Number": null,
"Address": "",
"PhoneNumber": "",
"FaxNumber": "",
"AccountManager": "",
"AccountEmail": "",
"Code": "",
"SlaId": null,
"ServiceCenter": 0,
"ServiceCenterName": "",
"Website": "",
"CustomerTypeId": null,
"PwCodeBlue": 0,
"PwInformProtectionSwitch": 0,
"PwInformDown": 0,
"PwInformAtRisk": 0,
"PwInformImPact": 0,
"PwInformNoImPact": 0,
"PwExtraInfo": "",
"PwLanguage": "",
"CountryId": null,
"Sla": null,
"Sites": null,
"Nodes": null,
"Racks": null,
"Orders": null,
"PwInformedList": null,
"Circuits": null,
"OloCircuits": null,
"ChannelReservations": null,
"PortReservations": null,
"IpRanges": null,
"NumberManagementList": null,
"CustomerRelatedContacts": null,
"CustomerRelatedContracts": null,
"InNumbers": null,
"ManagementSystems": null,
"CustomerType": null,
"ContractCustomerRelations": null,
"ParentCustomer": null,
"SubCustomers": null,
"EsimProfiles": null,
"Esims": null,
"Country": null,
"PwEmailSetups": null,
"TelephoneNumbers": null,
"TelephoneNumberRanges": null,
"RowVersion": "2016-05-18T10:20:38",
"Errors": null,
"HasErrors": false
},
{
"Id": 57603,
"ParentCustomerId": null,
"Name": "DUMMY 2",
"FullName": "DUMMY 2",
"Number": null,
"Address": "",
"PhoneNumber": "",
"FaxNumber": "",
"AccountManager": "",
"AccountEmail": "",
"Code": "",
"SlaId": null,
"ServiceCenter": 0,
"ServiceCenterName": "",
"Website": "",
"CustomerTypeId": 1,
"PwCodeBlue": 0,
"PwInformProtectionSwitch": 1,
"PwInformDown": 1,
"PwInformAtRisk": 1,
"PwInformImPact": 1,
"PwInformNoImPact": 1,
"PwExtraInfo": "",
"PwLanguage": "",
"CountryId": null,
"Sla": null,
"Sites": null,
"Nodes": null,
"Racks": null,
"Orders": null,
"PwInformedList": null,
"Circuits": null,
"OloCircuits": null,
"ChannelReservations": null,
"PortReservations": null,
"IpRanges": null,
"NumberManagementList": null,
"CustomerRelatedContacts": null,
"CustomerRelatedContracts": null,
"InNumbers": null,
"ManagementSystems": null,
"CustomerType": null,
"ContractCustomerRelations": null,
"ParentCustomer": null,
"SubCustomers": null,
"EsimProfiles": null,
"Esims": null,
"Country": null,
"PwEmailSetups": null,
"TelephoneNumbers": null,
"TelephoneNumberRanges": null,
"RowVersion": "2020-01-31T13:35:07",
"Errors": null,
"HasErrors": false
},
{
"Id": 57604,
"ParentCustomerId": null,
"Name": "DUMMY 3",
"FullName": "DUMMY 3",
"Number": null,
"Address": "",
"PhoneNumber": "",
"FaxNumber": "",
"AccountManager": "",
"AccountEmail": "",
"Code": "",
"SlaId": null,
"ServiceCenter": 0,
"ServiceCenterName": "",
"Website": "",
"CustomerTypeId": 1,
"PwCodeBlue": 0,
"PwInformProtectionSwitch": 1,
"PwInformDown": 1,
"PwInformAtRisk": 1,
"PwInformImPact": 1,
"PwInformNoImPact": 1,
"PwExtraInfo": "",
"PwLanguage": "",
"CountryId": null,
"Sla": null,
"Sites": null,
"Nodes": null,
"Racks": null,
"Orders": null,
"PwInformedList": null,
"Circuits": null,
"OloCircuits": null,
"ChannelReservations": null,
"PortReservations": null,
"IpRanges": null,
"NumberManagementList": null,
"CustomerRelatedContacts": null,
"CustomerRelatedContracts": null,
"InNumbers": null,
"ManagementSystems": null,
"CustomerType": null,
"ContractCustomerRelations": null,
"ParentCustomer": null,
"SubCustomers": null,
"EsimProfiles": null,
"Esims": null,
"Country": null,
"PwEmailSetups": null,
"TelephoneNumbers": null,
"TelephoneNumberRanges": null,
"RowVersion": "2020-01-31T13:35:07",
"Errors": null,
"HasErrors": false
}
],
"Vendor": [
{
"Id": 2482,
"Name": "DUMMY 4",
"TypeId": 1,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "TESTVENDORDESCRIPTION",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": null,
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-23T16:34:30",
"Errors": null,
"HasErrors": false
},
{
"Id": 2502,
"Name": "DUMMY 5",
"TypeId": 13,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": null,
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-31T13:30:42",
"Errors": null,
"HasErrors": false
},
{
"Id": 2503,
"Name": "DUMMY 2",
"TypeId": 14,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": null,
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-31T13:30:42",
"Errors": null,
"HasErrors": false
}
]
}
\ No newline at end of file
{"Customer": [{"id": 57284, "parentcustomerid": null, "name": "DUMMY 1", "fullname": "DUMMY 1", "number": null, "address": "", "phonenumber": "", "faxnumber": "", "accountmanager": "", "accountemail": "", "code": "", "slaid": null, "servicecenter": 0, "servicecentername": "", "website": "", "customertypeid": null, "pwcodeblue": 0, "pwinformprotectionswitch": 0, "pwinformdown": 0, "pwinformatrisk": 0, "pwinformimpact": 0, "pwinformnoimpact": 0, "pwextrainfo": "", "pwlanguage": "", "countryid": null, "sla": null, "sites": null, "nodes": null, "racks": null, "orders": null, "pwinformedlist": null, "circuits": null, "olocircuits": null, "channelreservations": null, "portreservations": null, "ipranges": null, "numbermanagementlist": null, "customerrelatedcontacts": null, "customerrelatedcontracts": null, "innumbers": null, "managementsystems": null, "customertype": null, "contractcustomerrelations": null, "parentcustomer": null, "subcustomers": null, "esimprofiles": null, "esims": null, "country": null, "pwemailsetups": null, "telephonenumbers": null, "telephonenumberranges": null, "rowversion": "2016-05-18T10:20:38", "errors": null, "haserrors": false}, {"id": 57603, "parentcustomerid": null, "name": "DUMMY 2", "fullname": "DUMMY 2", "number": null, "address": "", "phonenumber": "", "faxnumber": "", "accountmanager": "", "accountemail": "", "code": "", "slaid": null, "servicecenter": 0, "servicecentername": "", "website": "", "customertypeid": 1, "pwcodeblue": 0, "pwinformprotectionswitch": 1, "pwinformdown": 1, "pwinformatrisk": 1, "pwinformimpact": 1, "pwinformnoimpact": 1, "pwextrainfo": "", "pwlanguage": "", "countryid": null, "sla": null, "sites": null, "nodes": null, "racks": null, "orders": null, "pwinformedlist": null, "circuits": null, "olocircuits": null, "channelreservations": null, "portreservations": null, "ipranges": null, "numbermanagementlist": null, "customerrelatedcontacts": null, "customerrelatedcontracts": null, "innumbers": null, "managementsystems": null, "customertype": null, "contractcustomerrelations": null, "parentcustomer": null, "subcustomers": null, "esimprofiles": null, "esims": null, "country": null, "pwemailsetups": null, "telephonenumbers": null, "telephonenumberranges": null, "rowversion": "2020-01-31T13:35:07", "errors": null, "haserrors": false}, {"id": 57604, "parentcustomerid": null, "name": "DUMMY 3", "fullname": "DUMMY 3", "number": null, "address": "", "phonenumber": "", "faxnumber": "", "accountmanager": "", "accountemail": "", "code": "", "slaid": null, "servicecenter": 0, "servicecentername": "", "website": "", "customertypeid": 1, "pwcodeblue": 0, "pwinformprotectionswitch": 1, "pwinformdown": 1, "pwinformatrisk": 1, "pwinformimpact": 1, "pwinformnoimpact": 1, "pwextrainfo": "", "pwlanguage": "", "countryid": null, "sla": null, "sites": null, "nodes": null, "racks": null, "orders": null, "pwinformedlist": null, "circuits": null, "olocircuits": null, "channelreservations": null, "portreservations": null, "ipranges": null, "numbermanagementlist": null, "customerrelatedcontacts": null, "customerrelatedcontracts": null, "innumbers": null, "managementsystems": null, "customertype": null, "contractcustomerrelations": null, "parentcustomer": null, "subcustomers": null, "esimprofiles": null, "esims": null, "country": null, "pwemailsetups": null, "telephonenumbers": null, "telephonenumberranges": null, "rowversion": "2020-01-31T13:35:07", "errors": null, "haserrors": false}], "Vendor": [{"id": 2482, "name": "DUMMY 4", "typeid": 1, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "TESTVENDORDESCRIPTION", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": null, "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-23T16:34:30", "errors": null, "haserrors": false}, {"id": 2502, "name": "DUMMY 5", "typeid": 13, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": null, "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-31T13:30:42", "errors": null, "haserrors": false}, {"id": 2503, "name": "DUMMY 2", "typeid": 14, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": null, "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-31T13:30:42", "errors": null, "haserrors": false}]}
This diff is collapsed.
[
{
"Id": 1288,
"MainTypeId": 1,
"VendorId": 2584,
"RelateTypeId": 2,
"ContactId": 1085,
"Vendor": {
"Id": 2584,
"Name": "DUMMY 10",
"TypeId": 1,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": [],
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-31T17:18:22",
"Errors": null,
"HasErrors": false
},
"Contact": {
"Id": 1085,
"IsGroup": 0,
"Name": "K D_FIRST",
"InFix": "K D_INFIX",
"LastName": "K D_LAST",
"Gender": "K GENDER",
"Phone": "K PHONE",
"Mobile": "K MOBILE",
"Fax": "K FAX",
"Webpage": "K WEB",
"Mail": "K@DUMMY10.FR",
"PlannedworkMail": "K PLANNED MAIL",
"TroubleticketMail": "K TT MAIL",
"JobTitle": "K JOB",
"Priority": null,
"PlannedWorkMailType": null,
"Language": "K LANG",
"PreFix": "K PREFIX",
"SmsQuery": "K SMS",
"ExtraInfo": "K EXTRA",
"CustomerRelatedContacts": null,
"ContactRelatedContacts": null,
"MainContactRelatedContacts": null,
"SiteRelatedContacts": null,
"VendorRelatedContacts": [],
"QueueContacts": null,
"RowVersion": "2020-03-03T19:26:42",
"Errors": null,
"HasErrors": false
},
"RowVersion": "2020-03-04T16:33:09",
"Errors": null,
"HasErrors": false
},
{
"Id": 1289,
"MainTypeId": 1,
"VendorId": 2584,
"RelateTypeId": 2,
"ContactId": 1092,
"Vendor": {
"Id": 2584,
"Name": "DUMMY 11",
"TypeId": 1,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": [],
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-31T17:18:22",
"Errors": null,
"HasErrors": false
},
"Contact": {
"Id": 1092,
"IsGroup": 1,
"Name": "L DUMMY FIRST",
"InFix": "",
"LastName": "-",
"Gender": "",
"Phone": "",
"Mobile": "",
"Fax": "",
"Webpage": "",
"Mail": "L_DUMMY@DUMM11.COM",
"PlannedworkMail": "",
"TroubleticketMail": "",
"JobTitle": "",
"Priority": null,
"PlannedWorkMailType": null,
"Language": "",
"PreFix": "",
"SmsQuery": "",
"ExtraInfo": "",
"CustomerRelatedContacts": null,
"ContactRelatedContacts": null,
"MainContactRelatedContacts": null,
"SiteRelatedContacts": null,
"VendorRelatedContacts": [],
"QueueContacts": null,
"RowVersion": "2020-03-03T19:26:43",
"Errors": null,
"HasErrors": false
},
"RowVersion": "2020-03-04T16:33:09",
"Errors": null,
"HasErrors": false
},
{
"Id": 1290,
"MainTypeId": 1,
"VendorId": 2584,
"RelateTypeId": 2,
"ContactId": 1093,
"Vendor": {
"Id": 2584,
"Name": "DUMMY 12",
"TypeId": 1,
"SlaOnSiteId": null,
"SlaMainTimeToRepairId": null,
"SlaLink": "",
"SlaDescription": "",
"Description": "",
"SpareOwner": "",
"StockLocation": "",
"StockContact": "",
"InternetAddress": "",
"MasterAccount": "",
"EscalationDescription": "",
"Color": "",
"IssuerCodeEsim": null,
"MnoCode": "",
"EumId": "",
"EquipmentDefinitions": null,
"ManagementSystems": null,
"CardCodes": null,
"CardDefinitions": null,
"CableTypes": null,
"VendorRelatedContacts": [],
"VendorMaterialTypes": null,
"Contract": null,
"SlaOnSite": null,
"SlaMainTimeToRepair": null,
"Type": null,
"RowVersion": "2020-01-31T17:18:22",
"Errors": null,
"HasErrors": false
},
"Contact": {
"Id": 1093,
"IsGroup": 1,
"Name": "M FIRST",
"InFix": "",
"LastName": "M LAST",
"Gender": "",
"Phone": "M PHONE",
"Mobile": "",
"Fax": "",
"Webpage": "",
"Mail": "M@DUMMY12.DE",
"PlannedworkMail": "",
"TroubleticketMail": "",
"JobTitle": "",
"Priority": null,
"PlannedWorkMailType": null,
"Language": "",
"PreFix": "",
"SmsQuery": "",
"ExtraInfo": "",
"CustomerRelatedContacts": null,
"ContactRelatedContacts": null,
"MainContactRelatedContacts": null,
"SiteRelatedContacts": null,
"VendorRelatedContacts": [],
"QueueContacts": null,
"RowVersion": "2020-03-03T19:26:43",
"Errors": null,
"HasErrors": false
},
"RowVersion": "2020-03-04T16:33:09",
"Errors": null,
"HasErrors": false
}
]
\ No newline at end of file
[{"id": 1288, "maintypeid": 1, "vendorid": 2584, "relatetypeid": 2, "contactid": 1085, "vendor": {"id": 2584, "name": "DUMMY 10", "typeid": 1, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": [], "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-31T17:18:22", "errors": null, "haserrors": false}, "contact": {"id": 1085, "isgroup": 0, "name": "K D_FIRST", "infix": "K D_INFIX", "lastname": "K D_LAST", "gender": "K GENDER", "phone": "K PHONE", "mobile": "K MOBILE", "fax": "K FAX", "webpage": "K WEB", "mail": "K@DUMMY10.FR", "plannedworkmail": "K PLANNED MAIL", "troubleticketmail": "K TT MAIL", "jobtitle": "K JOB", "priority": null, "plannedworkmailtype": null, "language": "K LANG", "prefix": "K PREFIX", "smsquery": "K SMS", "extrainfo": "K EXTRA", "customerrelatedcontacts": null, "contactrelatedcontacts": null, "maincontactrelatedcontacts": null, "siterelatedcontacts": null, "vendorrelatedcontacts": [], "queuecontacts": null, "rowversion": "2020-03-03T19:26:42", "errors": null, "haserrors": false}, "rowversion": "2020-03-04T16:33:09", "errors": null, "haserrors": false}, {"id": 1289, "maintypeid": 1, "vendorid": 2584, "relatetypeid": 2, "contactid": 1092, "vendor": {"id": 2584, "name": "DUMMY 11", "typeid": 1, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": [], "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-31T17:18:22", "errors": null, "haserrors": false}, "contact": {"id": 1092, "isgroup": 1, "name": "L DUMMY FIRST", "infix": "", "lastname": "-", "gender": "", "phone": "", "mobile": "", "fax": "", "webpage": "", "mail": "L_DUMMY@DUMM11.COM", "plannedworkmail": "", "troubleticketmail": "", "jobtitle": "", "priority": null, "plannedworkmailtype": null, "language": "", "prefix": "", "smsquery": "", "extrainfo": "", "customerrelatedcontacts": null, "contactrelatedcontacts": null, "maincontactrelatedcontacts": null, "siterelatedcontacts": null, "vendorrelatedcontacts": [], "queuecontacts": null, "rowversion": "2020-03-03T19:26:43", "errors": null, "haserrors": false}, "rowversion": "2020-03-04T16:33:09", "errors": null, "haserrors": false}, {"id": 1290, "maintypeid": 1, "vendorid": 2584, "relatetypeid": 2, "contactid": 1093, "vendor": {"id": 2584, "name": "DUMMY 12", "typeid": 1, "slaonsiteid": null, "slamaintimetorepairid": null, "slalink": "", "sladescription": "", "description": "", "spareowner": "", "stocklocation": "", "stockcontact": "", "internetaddress": "", "masteraccount": "", "escalationdescription": "", "color": "", "issuercodeesim": null, "mnocode": "", "eumid": "", "equipmentdefinitions": null, "managementsystems": null, "cardcodes": null, "carddefinitions": null, "cabletypes": null, "vendorrelatedcontacts": [], "vendormaterialtypes": null, "contract": null, "slaonsite": null, "slamaintimetorepair": null, "type": null, "rowversion": "2020-01-31T17:18:22", "errors": null, "haserrors": false}, "contact": {"id": 1093, "isgroup": 1, "name": "M FIRST", "infix": "", "lastname": "M LAST", "gender": "", "phone": "M PHONE", "mobile": "", "fax": "", "webpage": "", "mail": "M@DUMMY12.DE", "plannedworkmail": "", "troubleticketmail": "", "jobtitle": "", "priority": null, "plannedworkmailtype": null, "language": "", "prefix": "", "smsquery": "", "extrainfo": "", "customerrelatedcontacts": null, "contactrelatedcontacts": null, "maincontactrelatedcontacts": null, "siterelatedcontacts": null, "vendorrelatedcontacts": [], "queuecontacts": null, "rowversion": "2020-03-03T19:26:43", "errors": null, "haserrors": false}, "rowversion": "2020-03-04T16:33:09", "errors": null, "haserrors": false}]
\ No newline at end of file
......@@ -17,6 +17,7 @@ def test_ims_class_login(mocker):
mock_post = mocker.patch('inventory_provider.db.ims.requests.post')
mock_get = mocker.patch('inventory_provider.db.ims.requests.get')
mock_post.return_value = MockResponse("my_bearer_token", 200)
mock_post.return_value.text = "my_bearer_token"
ds = inventory_provider.db.ims.IMS(
'dummy_base', 'dummy_username', 'dummy_password')
......@@ -25,7 +26,7 @@ def test_ims_class_login(mocker):
'dummy_base/login', auth=('dummy_username', 'dummy_password'))
mock_get.assert_called_once_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'my_bearer_token'},
headers={'Authorization': 'Bearer my_bearer_token'},
params=None)
......@@ -37,7 +38,7 @@ def test_ims_class_entity_by_id(mocker):
ds.get_entity_by_id('Node', 1234)
mock_get.assert_called_once_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params=None)
......@@ -49,7 +50,7 @@ def test_ims_class_entity_by_name(mocker):
ds.get_entity_by_name('Node', 'dummy_name')
mock_get.assert_called_once_with(
'dummy_base/ims/Node/byname/dummy_name',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params=None)
......@@ -61,7 +62,7 @@ def test_ims_class_filtered_entities(mocker):
list(ds.get_filtered_entities('Node', 'dummy_param=dummy value'))
mock_get.assert_called_once_with(
'dummy_base/ims/Node/filtered/dummy_param=dummy value',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements':
......@@ -81,14 +82,14 @@ def test_ims_class_filtered_entities(mocker):
res = list(ds.get_filtered_entities('Node', 'dummy_param=dummy value'))
mock_multi_get.assert_any_call(
'dummy_base/ims/Node/filtered/dummy_param=dummy value',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements': 2
})
mock_multi_get.assert_any_call(
'dummy_base/ims/Node/filtered/dummy_param=dummy value',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params={
'paginatorStartElement': 2,
'paginatorNumberOfElements': 2
......@@ -105,7 +106,7 @@ def test_ims_class_get_all_entities(mocker):
list(ds.get_all_entities('Node'))
mock_get.assert_called_once_with(
'dummy_base/ims/Node/filtered/Id <> 0',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements':
......@@ -121,7 +122,7 @@ def test_ims_class_navigation_properties(mocker):
ds.get_entity_by_id('Node', 1234, navigation_properties=[1, 2, 3])
mock_get.assert_called_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'dummy_bt'},
headers={'Authorization': 'Bearer dummy_bt'},
params={'navigationproperty': 6})
......
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