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
f39fdfb7
Commit
f39fdfb7
authored
2 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
updated tests
parent
6326324f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_ims_data.py
+17
-17
17 additions, 17 deletions
test/test_ims_data.py
test/test_worker.py
+41
-2
41 additions, 2 deletions
test/test_worker.py
with
58 additions
and
19 deletions
test/test_ims_data.py
+
17
−
17
View file @
f39fdfb7
...
...
@@ -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_
ent
iti
es
get_flexils_
by_circu
iti
d
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_
ent
iti
es
(
ds
)
)
res
=
get_flexils_
by_circu
iti
d
(
ds
)
assert
res
==
expected_result
This diff is collapsed.
Click to expand it.
test/test_worker.py
+
41
−
2
View file @
f39fdfb7
...
...
@@ -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
...
...
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