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
fb675d11
Commit
fb675d11
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added '/classifier/juniper-server-addresses' unit test
parent
aff4fd6a
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_classifier_routes.py
+37
-1
37 additions, 1 deletion
test/test_classifier_routes.py
with
37 additions
and
1 deletion
test/test_classifier_routes.py
+
37
−
1
View file @
fb675d11
...
...
@@ -7,7 +7,7 @@ DEFAULT_REQUEST_HEADERS = {
}
def
test_
version_requ
es
t
(
client
):
def
test_
infinera_address
es
(
client
):
response_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
...
...
@@ -22,3 +22,39 @@ def test_version_request(client):
json
.
loads
(
rv
.
data
.
decode
(
"
utf-8
"
)),
response_schema
)
def
test_juniper_addresses
(
mocker
,
client
):
test_data
=
[
{
"
ip_address
"
:
"
a.b.c.d
"
,
"
project_name
"
:
"
AAABBB
"
},
{
"
ip_address
"
:
"
b.c.d.e
"
,
"
project_name
"
:
"
CCCCDDDDD
"
},
{
"
ip_address
"
:
"
c.d.e.f
"
,
"
project_name
"
:
"
EFEFEFEF
"
},
{
"
ip_address
"
:
"
::1
"
,
"
project_name
"
:
"
GGHHGGHH
"
}
]
class
MockedRedis
():
def
__init__
(
self
):
pass
def
get
(
self
,
ignored
):
return
json
.
dumps
(
test_data
).
encode
(
'
utf-8
'
)
mocker
.
patch
(
'
inventory_provider.routes.classifier.db.get_redis
'
,
return_value
=
MockedRedis
())
response_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
"
items
"
:
{
"
type
"
:
"
string
"
}
}
rv
=
client
.
post
(
"
/classifier/juniper-server-addresses
"
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
response_data
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
jsonschema
.
validate
(
response_data
,
response_schema
)
assert
len
(
response_data
)
==
len
(
test_data
)
assert
set
([
x
[
'
ip_address
'
]
for
x
in
test_data
])
==
set
(
response_data
)
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