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
308ad5d8
Commit
308ad5d8
authored
8 months ago
by
Pelle Koster
Browse files
Options
Downloads
Patches
Plain Diff
DBOARD3-1005: small fix to using ils data snapshot
parent
89611ffb
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
inventory_provider/db/ims_data.py
+14
-1
14 additions, 1 deletion
inventory_provider/db/ims_data.py
test/test_ims_data.py
+16
-17
16 additions, 17 deletions
test/test_ims_data.py
with
30 additions
and
18 deletions
inventory_provider/db/ims_data.py
+
14
−
1
View file @
308ad5d8
...
...
@@ -73,9 +73,22 @@ SITE_LOCATION_SCHEMA = {
}
def
_transform_key
(
key
):
if
key
==
"
null
"
:
return
None
try
:
return
int
(
key
)
except
ValueError
:
return
key
def
get_flexils_by_circuitid
(
ds
:
IMS
):
import
pathlib
return
json
.
loads
((
pathlib
.
Path
(
__file__
).
parent
/
'
flexils_data.json
'
).
read_text
())
raw_data
=
json
.
loads
(
(
pathlib
.
Path
(
__file__
).
parent
/
"
flexils_data.json
"
).
read_text
()
)
return
{
_transform_key
(
k
):
v
for
k
,
v
in
raw_data
.
items
()}
by_circuit
=
defaultdict
(
list
)
found_keys
=
set
()
...
...
This diff is collapsed.
Click to expand it.
test/test_ims_data.py
+
16
−
17
View file @
308ad5d8
...
...
@@ -10,7 +10,6 @@ from inventory_provider.db.ims_data import lookup_lg_routers, \
get_port_id_services
,
get_port_details
,
\
get_circuit_hierarchy
,
get_ids_and_sids
,
NODE_LOCATION_SCHEMA
,
\
get_flexils_by_circuitid
,
SITE_LOCATION_SCHEMA
,
get_site_locations
import
pytest
def
_json_test_data
(
filename
):
...
...
@@ -407,7 +406,6 @@ def test_get_circuit_ids_and_sids(mocker):
assert
res
==
expected_response
@pytest.mark.xfail
(
reason
=
"
Temporary using ims bypass for flexils
"
)
def
test_get_flexils_by_circuit_id
(
mocker
):
ims
=
mocker
.
patch
(
'
inventory_provider.db.ims.IMS
'
)
ims
.
return_value
.
get_all_entities
.
return_value
=
\
...
...
@@ -447,22 +445,23 @@ def test_get_flexils_by_circuit_id(mocker):
"
customproperties
"
:
{}
}
]
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
'
}
]
}
#
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
=
get_flexils_by_circuitid
(
ds
)
assert
res
==
expected_result
assert
all
(
isinstance
(
k
,
(
int
,
type
(
None
)))
for
k
in
res
)
# assert res == expected_result
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