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
7cb0f75c
Commit
7cb0f75c
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
general data route tests
parent
bd55569a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_ims_general_data_routes.py
+103
-0
103 additions, 0 deletions
test/test_ims_general_data_routes.py
with
103 additions
and
0 deletions
test/test_ims_general_data_routes.py
0 → 100644
+
103
−
0
View file @
7cb0f75c
import
contextlib
import
json
import
jsonschema
DEFAULT_REQUEST_HEADERS
=
{
"
Content-type
"
:
"
application/json
"
,
"
Accept
"
:
[
"
application/json
"
]
}
def
test_get_routers
(
ims_client
):
version_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
}
rv
=
ims_client
.
post
(
"
data/routers
"
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
response
=
json
.
loads
(
rv
.
data
.
decode
(
"
utf-8
"
))
jsonschema
.
validate
(
response
,
version_schema
)
assert
response
def
test_pop_info
(
ims_client
):
"""
just check the correct method is called, but mock out all sql access
"""
expected_pop_info
=
[{
"
equipment-name
"
:
"
MX1.LON.UK
"
,
"
status
"
:
"
operational
"
,
"
pop
"
:
{
"
name
"
:
"
LONDON
"
,
"
abbreviation
"
:
"
LON
"
,
"
country
"
:
"
UNITED KINGDOM
"
,
"
city
"
:
"
LONDON
"
,
"
longitude
"
:
-
0.0152639
,
"
latitude
"
:
51.4981657
}
}]
rv
=
ims_client
.
get
(
'
/data/pop/mx1.lon.uk.geant.net
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
assert
rv
.
is_json
response
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
assert
response
==
expected_pop_info
def
test_pop_not_found
(
ims_client
,
mocker
):
"""
just check the correct method is called, but mock out all sql access
"""
rv
=
ims_client
.
get
(
'
/data/pop/aabbcc
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
404
def
test_router_interfaces_all
(
ims_client
):
interfaces_list_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
object
"
,
"
properties
"
:
{
"
name
"
:
{
"
type
"
:
"
string
"
},
"
description
"
:
{
"
type
"
:
"
string
"
},
"
router
"
:
{
"
type
"
:
"
string
"
},
"
bundle
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
},
"
ipv4
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
},
"
ipv6
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
}
},
"
required
"
:
[
"
name
"
,
"
description
"
,
"
ipv4
"
,
"
router
"
,
"
ipv6
"
],
"
additionalProperties
"
:
False
}
}
rv
=
ims_client
.
post
(
'
/orig-data/interfaces
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
response
=
json
.
loads
(
rv
.
data
.
decode
(
"
utf-8
"
))
jsonschema
.
validate
(
response
,
interfaces_list_schema
)
assert
response
# at least shouldn't be empty
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