Skip to content
Snippets Groups Projects
Commit e61e5eab authored by Erik Reid's avatar Erik Reid
Browse files

added test of _build_subnet_db

parent 293cb364
No related branches found
No related tags found
No related merge requests found
"""
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment