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
67544728
Commit
67544728
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
updated pop location tests to use abbreviations
parent
811b44a1
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
inventory_provider/routes/neteng.py
+9
-9
9 additions, 9 deletions
inventory_provider/routes/neteng.py
test/test_neteng_routes.py
+2
-2
2 additions, 2 deletions
test/test_neteng_routes.py
with
11 additions
and
11 deletions
inventory_provider/routes/neteng.py
+
9
−
9
View file @
67544728
...
...
@@ -71,14 +71,14 @@ def get_location(equipment):
value
=
r
.
get
(
f
'
ims:location:
{
equipment
}
'
)
if
not
value
:
return
Response
(
response
=
'
no location information available for
"
{equipment}
"'
,
response
=
f
'
no location information available for
"
{
equipment
}
"'
,
status
=
404
,
mimetype
=
'
text/html
'
)
value
=
json
.
loads
(
value
.
decode
(
'
utf-8
'
))
if
not
value
:
return
Response
(
response
=
'
unexpected empty cached data for
"
{equipment}
"'
,
response
=
f
'
unexpected empty cached data for
"
{
equipment
}
"'
,
status
=
500
,
mimetype
=
'
text/html
'
)
...
...
@@ -92,7 +92,7 @@ def get_pop_names():
Handler for `/neteng/pops`
This method will return a list of defined pop
name
s. Elements from this list can be used
abbreviation
s. Elements from this list can be used
with `/neteng/pop`.
.. asjson::
...
...
@@ -111,14 +111,14 @@ def get_pop_names():
return
jsonify
(
sorted
(
list
(
_pops
())))
@routes.route
(
'
/pop/<
name
>
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@routes.route
(
'
/pop/<
abbreviation
>
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
def
get_pop_location
(
name
):
def
get_pop_location
(
abbreviation
):
"""
Handler for `/neteng/pop/<name>`
This method will return location information for the POP
with
name = `name
` in IMS.
with
abbreviation = `abbreviation
` in IMS.
404 is returned if the POP name is not known.
Otherwise the return value will be formatted as:
...
...
@@ -131,17 +131,17 @@ def get_pop_location(name):
r
=
common
.
get_current_redis
()
value
=
r
.
get
(
f
'
ims:pop:
{
name
}
'
)
value
=
r
.
get
(
f
'
ims:pop:
{
abbreviation
}
'
)
if
not
value
:
return
Response
(
response
=
'
no location information available for
"
{
pop
}
"'
,
response
=
f
'
no location information available for
"
{
abbreviation
}
"'
,
status
=
404
,
mimetype
=
'
text/html
'
)
value
=
json
.
loads
(
value
.
decode
(
'
utf-8
'
))
if
not
value
:
return
Response
(
response
=
'
unexpected empty cached data for
"
{
name
}
"'
,
response
=
f
'
unexpected empty cached data for
"
{
abbreviation
}
"'
,
status
=
500
,
mimetype
=
'
text/html
'
)
...
...
This diff is collapsed.
Click to expand it.
test/test_neteng_routes.py
+
2
−
2
View file @
67544728
...
...
@@ -40,7 +40,7 @@ def test_get_pops(client, mocked_redis):
@pytest.mark.parametrize
(
'
pop_name
'
,
[
'
AMS
TERDAM
'
,
'
VIENNA
'
,
'
LON
DON
'
,
'
LONDON 2
'
'
AMS
'
,
'
LON
'
,
'
LON
2
'
,
'
ORB
'
,
'
ORBE
'
])
def
test_pop_location
(
client
,
mocked_redis
,
pop_name
):
rv
=
client
.
post
(
...
...
@@ -56,6 +56,6 @@ def test_pop_location(client, mocked_redis, pop_name):
def
test_pop_not_found
(
client
,
mocked_redis
):
rv
=
client
.
post
(
'
/neteng/pop/BOGUS.POP.
NAME
'
,
'
/neteng/pop/BOGUS.POP.
ABBREV
'
,
headers
=
{
'
Accept
'
:
[
'
application/json
'
]})
assert
rv
.
status_code
==
404
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