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
b94bc177
Commit
b94bc177
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
add router response schema validation
parent
aafef5e0
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
README.md
+16
-1
16 additions, 1 deletion
README.md
test/test_data_routes.py
+11
-3
11 additions, 3 deletions
test/test_data_routes.py
with
27 additions
and
4 deletions
README.md
+
16
−
1
View file @
b94bc177
...
...
@@ -118,9 +118,11 @@ The following resources can be requested from the webservice.
### synchronous resources
All responses are JSON formatted messages.
*
`/data/version`
The response will be a
JSON message formatted
object
The response will be a
n
object
containing the module and protocol versions of the
running server and will be formatted as follows:
...
...
@@ -143,3 +145,16 @@ The following resources can be requested from the webservice.
}
```
*
/data/routers
The response will be a list of router hostnames
for which information is available and will be
formatted as follows:
```
json
{
"$schema"
:
"http://json-schema.org/draft-07/schema#"
,
"type"
:
"array"
,
"items"
:
{
"type"
:
"string"
}
}
```
This diff is collapsed.
Click to expand it.
test/test_data_routes.py
+
11
−
3
View file @
b94bc177
...
...
@@ -187,7 +187,14 @@ class MockedRedis(object):
return
MockedRedis
.
db
.
keys
()
def
test_abc
(
mocker
,
client
):
def
test_routers_list
(
mocker
,
client
):
routers_list_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
}
mocker
.
patch
(
'
inventory_provider.router_details.redis.StrictRedis
'
,
MockedRedis
)
...
...
@@ -199,5 +206,6 @@ def test_abc(mocker, client):
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
rsp
=
rv
.
data
.
decode
(
"
utf-8
"
)
print
(
rsp
)
response
=
json
.
loads
(
rv
.
data
.
decode
(
"
utf-8
"
))
jsonschema
.
validate
(
response
,
routers_list_schema
)
assert
response
# 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