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
8478646f
Commit
8478646f
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
use cache data for classifer test
parent
8c799a73
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_classifier_routes.py
+4
-45
4 additions, 45 deletions
test/test_classifier_routes.py
with
4 additions
and
45 deletions
test/test_classifier_routes.py
+
4
−
45
View file @
8478646f
...
...
@@ -41,24 +41,6 @@ def test_coriant_addresses(client):
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
,
*
args
,
**
kwargs
):
pass
def
get
(
self
,
ignored
):
return
json
.
dumps
(
test_data
).
encode
(
'
utf-8
'
)
mocker
.
patch
(
'
inventory_provider.routes.common.redis.StrictRedis
'
,
MockedRedis
)
response_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
array
"
,
...
...
@@ -71,39 +53,16 @@ def test_juniper_addresses(mocker, client):
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
)
assert
len
(
response_data
)
>
0
# test data is not empty
def
test_trap_metadata
(
mocker
,
client
):
test_data
=
[
{
"
equipment
"
:
"
test-equipment
"
,
"
manufacturer
"
:
"
test-manufacturer
"
,
"
vendor
"
:
"
test-vendor
"
,
"
absid
"
:
"
1234
"
,
"
name
"
:
"
test-service_1
"
},
{
"
equipment
"
:
"
test-equipment
"
,
"
manufacturer
"
:
"
test-manufacturer
"
,
"
vendor
"
:
"
test-vendor
"
,
"
absid
"
:
"
2345
"
,
"
name
"
:
"
test-service_2
"
}
]
mocked_redis
=
mocker
.
patch
(
"
inventory_provider.routes.common.get_redis
"
)
mocked_redis
.
return_value
.
hget
.
return_value
=
json
.
dumps
(
test_data
)
\
.
encode
(
"
utf-8
"
)
def
test_trap_metadata
(
client_with_mocked_data
):
response_schema
=
{
"
$schema
"
:
"
http://json-schema.org/draft-07/schema#
"
,
"
type
"
:
"
object
"
}
rv
=
client
.
get
(
'
/classifier/trap-metadata/BGP/dummy-equipment/xe-2/3/1
'
,
rv
=
client_with_mocked_data
.
get
(
'
/classifier/trap-metadata/BGP/mx1.ams.nl.geant.net/ae15.1500
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
assert
rv
.
is_json
...
...
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