From 16a74fb4c171e3239760fbaec07e0b1c3458c50d Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Fri, 12 Mar 2021 12:37:27 +0100 Subject: [PATCH] verify that unmanaged interfaces in imported --- test/test_worker_utils.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test_worker_utils.py b/test/test_worker_utils.py index 198bc43b..f8776328 100644 --- a/test/test_worker_utils.py +++ b/test/test_worker_utils.py @@ -11,6 +11,7 @@ import jsonschema from inventory_provider.tasks import worker from inventory_provider.tasks import common from inventory_provider.routes import msr +from inventory_provider import config def backend_db(): @@ -23,7 +24,7 @@ def backend_db(): }).db -def test_build_subnet_db(mocked_worker_module): +def test_build_subnet_db(mocked_worker_module, data_config_filename): """ Verify that valid reverse subnet objects are created. @@ -52,6 +53,16 @@ def test_build_subnet_db(mocked_worker_module): 'items': {"$ref": "#/definitions/interface"}, } + all_subnet_interfaces = set() + unmanaged_interfaces = set() + with open(data_config_filename) as f: + params = config.load(f) + for ifc in params.get('unmanaged-interfaces', []): + ifc_key = (f'{ifc["router"].lower()}' + f':{ifc["interface"].lower()}' + f':{ifc["network"]}') + unmanaged_interfaces.add(ifc_key) + db = backend_db() # also forces initialization def _x(k): @@ -80,8 +91,17 @@ def test_build_subnet_db(mocked_worker_module): for ifc in value: assert ifc['interface address'] == address + ifc_key = (f'{ifc["router"]}' + f':{ifc["interface name"]}' + f':{ifc["interface address"]}') + + all_subnet_interfaces.add(ifc_key) + assert found_record + assert unmanaged_interfaces <= all_subnet_interfaces + + def test_build_juniper_peering_db(mocked_worker_module): """ -- GitLab