Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
bb82e443
Commit
bb82e443
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added test for OTRS Customer Company export
parent
454faec9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/data/ims_otrs_customers.json
+276
-0
276 additions, 0 deletions
test/data/ims_otrs_customers.json
test/test_ims_data.py
+31
-3
31 additions, 3 deletions
test/test_ims_data.py
with
307 additions
and
3 deletions
test/data/ims_otrs_customers.json
0 → 100644
+
276
−
0
View file @
bb82e443
{
"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
This diff is collapsed.
Click to expand it.
test/test_ims_data.py
+
31
−
3
View file @
bb82e443
...
...
@@ -2,7 +2,8 @@ import json
import
inventory_provider
from
inventory_provider.db.ims
import
InventoryStatus
from
inventory_provider.db.ims_data
import
lookup_pop_info
,
lookup_lg_routers
from
inventory_provider.db.ims_data
import
lookup_pop_info
,
lookup_lg_routers
,
\
otrs_get_customer_company_rows
def
test_lookup_lg_routers
(
mocker
):
...
...
@@ -29,7 +30,7 @@ def test_lookup_lg_routers(mocker):
}
ds
=
inventory_provider
.
db
.
ims
.
IMS
(
'
dummy_base
'
,
'
dmmy_username
'
,
'
dummy_password
'
)
'
dummy_base
'
,
'
d
u
mmy_username
'
,
'
dummy_password
'
)
res
=
list
(
lookup_lg_routers
(
ds
))
...
...
@@ -66,7 +67,7 @@ def test_lookup_pop_info(mocker):
ims
.
return_value
.
get_entity_by_id
.
return_value
=
resp_data
[
'
site
'
]
ds
=
inventory_provider
.
db
.
ims
.
IMS
(
'
dummy_base
'
,
'
dmmy_username
'
,
'
dummy_password
'
)
'
dummy_base
'
,
'
d
u
mmy_username
'
,
'
dummy_password
'
)
res
=
lookup_pop_info
(
ds
,
'
dummy_host
'
)
ds
.
get_entity_by_name
.
assert_called_once_with
(
'
Node
'
,
'
dummy_host
'
)
ds
.
get_entity_by_id
.
assert_called_once_with
(
...
...
@@ -83,3 +84,30 @@ def test_lookup_pop_info(mocker):
'
latitude
'
:
50.10166667
,
}
}
def
test_otrs_get_customer_company_rows
(
mocker
):
ims
=
mocker
.
patch
(
'
inventory_provider.db.ims.IMS
'
)
with
open
(
'
test/data/ims_otrs_customers.json
'
)
as
data
:
resp_data
=
json
.
load
(
data
)
def
se
(
*
args
,
**
kargs
):
return
resp_data
[
args
[
0
]]
mocked_get_all_entities
=
ims
.
return_value
.
get_all_entities
mocked_get_all_entities
.
side_effect
=
se
ds
=
inventory_provider
.
db
.
ims
.
IMS
(
'
dummy_base
'
,
'
dummy_username
'
,
'
dummy_password
'
)
cus_comp_rows
=
list
(
otrs_get_customer_company_rows
(
ds
))
assert
len
(
cus_comp_rows
)
==
6
mocked_get_all_entities
.
assert_any_call
(
'
Customer
'
)
mocked_get_all_entities
.
assert_any_call
(
'
Vendor
'
)
assert
cus_comp_rows
[
0
]
==
[
'
customer_id
'
,
'
name
'
,
'
street
'
,
'
zip
'
,
'
city
'
,
'
country
'
,
'
url
'
,
'
comments
'
]
ids
=
[]
names
=
[]
for
row
in
cus_comp_rows
[
1
:]:
assert
len
(
row
)
==
8
ids
.
append
(
row
[
0
])
names
.
append
(
row
[
1
])
assert
ids
==
[
'
DUMMY1
'
,
'
DUMMY2
'
,
'
DUMMY3
'
,
'
DUMMY4
'
,
'
DUMMY5
'
]
assert
names
==
[
'
DUMMY 1
'
,
'
DUMMY 2
'
,
'
DUMMY 3
'
,
'
DUMMY 4
'
,
'
DUMMY 5
'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment