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
13b712d5
Commit
13b712d5
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
basic unit test
parent
5734acb1
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
test/conftest.py
+11
-2
11 additions, 2 deletions
test/conftest.py
test/test_msr_routes.py
+121
-1
121 additions, 1 deletion
test/test_msr_routes.py
with
132 additions
and
3 deletions
test/conftest.py
+
11
−
2
View file @
13b712d5
...
...
@@ -5,6 +5,7 @@ import netifaces
import
os
import
re
import
tempfile
import
threading
from
lxml
import
etree
import
pytest
...
...
@@ -92,13 +93,21 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join(
"
data
"
))
_bootstrap_semaphore
=
threading
.
Semaphore
()
class
MockedRedis
(
object
):
db
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
MockedRedis
.
db
is
None
:
MockedRedis
.
prep
()
_bootstrap_semaphore
.
acquire
()
try
:
if
MockedRedis
.
db
is
None
:
MockedRedis
.
prep
()
finally
:
_bootstrap_semaphore
.
release
()
# allows us to create other mocks using a different data source file
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
test/test_msr_routes.py
+
121
−
1
View file @
13b712d5
...
...
@@ -4,7 +4,7 @@ import jsonschema
import
pytest
from
inventory_provider.routes.msr
import
PEERING_LIST_SCHEMA
,
\
PEERING_GROUP_LIST_SCHEMA
PEERING_GROUP_LIST_SCHEMA
,
IP_ADDRESS_LIST_SCHEMA
from
inventory_provider.routes.poller
import
SERVICES_LIST_SCHEMA
DEFAULT_REQUEST_HEADERS
=
{
...
...
@@ -135,3 +135,123 @@ def test_peerings_group_list(client, uri):
jsonschema
.
validate
(
response_data
,
PEERING_GROUP_LIST_SCHEMA
)
assert
response_data
# test data is non-empty
def
test_peering_services
(
client
):
# sample splunk output
payload
=
[
'
83.97.93.247
'
,
'
146.48.78.13
'
,
'
185.6.36.40
'
,
'
2a00:1620:c0:4e:146:48:78:13
'
,
'
62.40.125.102
'
,
'
62.40.126.11
'
,
'
62.40.127.141
'
,
'
62.40.98.11
'
,
'
62.40.102.19
'
,
'
202.179.249.33
'
,
'
202.179.249.209
'
,
'
138.44.226.6
'
,
'
138.44.226.8
'
,
'
203.30.38.92
'
,
'
195.66.226.140
'
,
'
195.66.224.122
'
,
'
62.40.124.226
'
,
'
80.81.194.138
'
,
'
62.40.127.139
'
,
'
80.81.195.40
'
,
'
80.81.194.152
'
,
'
62.40.125.154
'
,
'
62.40.124.147
'
,
'
62.40.100.39
'
,
'
62.40.126.222
'
,
'
83.97.88.197
'
,
'
83.97.88.166
'
,
'
91.210.16.114
'
,
'
62.40.126.146
'
,
'
62.40.100.45
'
,
'
62.40.125.198
'
,
'
2400:4500::1:0:32
'
,
'
62.40.126.230
'
,
'
117.103.111.142
'
,
'
91.210.16.5
'
,
'
195.66.227.152
'
,
'
91.210.16.63
'
,
'
62.40.109.146
'
,
'
64.57.30.209
'
,
'
198.124.80.29
'
,
'
62.40.125.78
'
,
'
192.84.8.13
'
,
'
62.40.124.242
'
,
'
185.1.47.55
'
,
'
83.97.89.222
'
,
'
185.1.47.54
'
,
'
83.97.88.228
'
,
'
83.97.88.229
'
,
'
83.97.90.2
'
,
'
195.66.224.207
'
,
'
83.97.89.242
'
,
'
62.40.124.249
'
,
'
62.40.126.37
'
,
'
195.66.226.230
'
,
'
62.40.124.222
'
,
'
185.6.36.75
'
,
'
80.249.210.1
'
,
'
62.40.124.230
'
,
'
198.124.80.9
'
,
'
83.97.88.162
'
,
'
62.40.125.130
'
,
'
195.66.225.63
'
,
'
80.81.195.189
'
,
'
195.66.225.121
'
,
'
62.40.125.167
'
,
'
195.66.225.142
'
,
'
62.40.125.18
'
,
'
91.210.16.113
'
,
'
80.249.210.95
'
,
'
80.249.209.34
'
,
'
62.40.125.238
'
,
'
83.97.88.102
'
,
'
80.81.194.165
'
,
'
62.40.125.254
'
,
'
83.97.88.106
'
,
'
91.210.16.202
'
,
'
80.249.208.164
'
,
'
185.1.192.59
'
,
'
195.66.226.180
'
,
'
62.40.125.134
'
,
'
83.97.89.17
'
,
'
62.40.126.3
'
,
'
80.249.209.232
'
,
'
83.97.88.34
'
,
'
185.1.47.48
'
,
'
83.97.89.250
'
,
'
83.97.88.185
'
,
'
80.249.209.53
'
,
'
62.40.125.174
'
,
'
205.189.32.76
'
,
'
185.6.36.55
'
,
'
185.6.36.28
'
,
'
80.81.195.168
'
,
'
62.40.125.42
'
,
'
80.81.192.43
'
,
'
83.97.88.206
'
,
'
62.40.100.59
'
,
'
62.40.125.118
'
,
'
62.40.124.150
'
,
'
83.97.88.46
'
]
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
headers
.
update
(
DEFAULT_REQUEST_HEADERS
)
rv
=
client
.
post
(
'
/msr/bgp/peering-services
'
,
headers
=
headers
,
data
=
json
.
dumps
(
payload
))
assert
rv
.
status_code
==
200
assert
rv
.
is_json
response_data
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
# jsonschema.validate(response_data, IP_ADDRESS_LIST_SCHEMA)
assert
response_data
# test data is non-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