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
e61e5eab
Commit
e61e5eab
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added test of _build_subnet_db
parent
293cb364
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_worker_utils.py
+45
-5
45 additions, 5 deletions
test/test_worker_utils.py
with
45 additions
and
5 deletions
test/test_worker_utils.py
+
45
−
5
View file @
e61e5eab
"""
tests of a few worker utilities
"""
import
contextlib
import
json
import
os
import
re
import
jsonschema
...
...
@@ -25,9 +23,8 @@ def backend_db():
def
test_build_interface_services
(
mocked_worker_module
):
"""
not a very meaningful test ... basically only for sanity & coverage
:param data_config:
:param mocked_redis:
checks that valid interface service objects are created
:param mocked_worker_module: fixture
:return:
"""
...
...
@@ -86,3 +83,46 @@ def test_build_interface_services(mocked_worker_module):
expected_seen_types
=
set
([
'
mdvpn
'
,
'
lhcone
'
])
assert
seen_types
==
expected_seen_types
def
test_build_subnet_db
(
mocked_worker_module
):
"""
checks that valid reverse subnet objects are created
:param mocked_worker_module: fixture
:return:
"""
address_schema
=
{
'
$schema
'
:
'
http://json-schema.org/draft-07/schema#
'
,
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
name
'
:
{
'
type
'
:
'
string
'
},
'
interface address
'
:
{
'
type
'
:
'
string
'
},
'
interface name
'
:
{
'
type
'
:
'
string
'
},
'
router
'
:
{
'
type
'
:
'
string
'
}
},
'
required
'
:
[
'
name
'
,
'
interface address
'
,
'
interface name
'
,
'
router
'
],
'
additionalProperties
'
:
False
}
db
=
backend_db
()
# also forces initialization
worker
.
_build_subnet_db
()
found_record
=
False
for
key
,
value
in
db
.
items
():
if
not
key
.
startswith
(
'
reverse_interface_addresses:
'
):
continue
found_record
=
True
m
=
re
.
match
(
'
^reverse_interface_addresses:(.+)
'
,
key
)
assert
m
address
=
m
.
group
(
1
)
value
=
json
.
loads
(
value
)
jsonschema
.
validate
(
value
,
address_schema
)
assert
value
[
'
name
'
]
==
address
assert
found_record
\ No newline at end of file
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