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

fix handling of snmp result list

parent bb37ccc7
Branches
Tags
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
just checks that the worker methods call the right functions just checks that the worker methods call the right functions
and some data ends up in the right place ... otherwise not very detailed and some data ends up in the right place ... otherwise not very detailed
""" """
import json
import logging import logging
from lxml import etree from lxml import etree
...@@ -17,6 +18,12 @@ class MockedRedis(object): ...@@ -17,6 +18,12 @@ class MockedRedis(object):
pass pass
def hset(self, name, key, value): def hset(self, name, key, value):
assert isinstance(value, str)
if key == 'netconf':
etree.fromstring(value)
elif key == 'snmp-interfaces':
obj = json.loads(value)
assert isinstance(obj, dict)
MockedRedis.db.setdefault(name, {})[key] = value MockedRedis.db.setdefault(name, {})[key] = value
...@@ -53,7 +60,7 @@ def test_snmp_refresh_interfaces( ...@@ -53,7 +60,7 @@ def test_snmp_refresh_interfaces(
mocked_worker_module, mocker, cached_test_data): mocked_worker_module, mocker, cached_test_data):
def _mocked_snmp_interfaces(hostname, community, _): def _mocked_snmp_interfaces(hostname, community, _):
return cached_test_data[hostname]["snmp-interfaces"] return json.loads(cached_test_data[hostname]["snmp-interfaces"])
mocker.patch( mocker.patch(
'inventory_provider.tasks.worker.snmp.get_router_interfaces', 'inventory_provider.tasks.worker.snmp.get_router_interfaces',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment