diff --git a/inventory_provider/tasks/common.py b/inventory_provider/tasks/common.py index 2d7f699f250d08a5db6fa344896fdf20712cb159..ac85afb7de7094517c95cf2ed5f2929b211f6afc 100644 --- a/inventory_provider/tasks/common.py +++ b/inventory_provider/tasks/common.py @@ -66,6 +66,7 @@ TASK_LOG_SCHEMA = { 'additionalProperties': False } + def get_latch(r): latch = r.get('db:latch') if latch is None: diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index cf861ded2d10158db2b9f72bc7c5cd2d61def8ba..48058c7cb3d2ad2db081e0a5b5c6d68649eae73f 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -111,7 +111,8 @@ def snmp_refresh_interfaces(self, hostname, community): def netconf_refresh_config(self, hostname): try: - netconf_doc = juniper.load_config(hostname, InventoryTask.config["ssh"]) + netconf_doc = juniper.load_config( + hostname, InventoryTask.config["ssh"]) netconf_str = etree.tostring(netconf_doc, encoding='unicode') except ConnectionError: msg = f'error loading netconf data from {hostname}' diff --git a/test/test_monitoring.py b/test/test_monitoring.py index f25d3793a214b6f8560db644e3c65a5d1032e474..66fa82851b4a4ccbeba942185f20a9567699e0e8 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -21,6 +21,7 @@ TEST_LOG_EVENTS = [ {'type': 'task-error', 'uuid': 'AAAA', 'clock': 777} ] + @contextlib.contextmanager def mocked_connection(): yield CONNECTION_FINGERPRINT @@ -56,8 +57,10 @@ def backend_db(): @mock.patch('inventory_provider.tasks.monitor.app.events.State', MockedState) -@mock.patch('inventory_provider.tasks.monitor.app.connection', mocked_connection) -@mock.patch('inventory_provider.tasks.monitor.app.events.Receiver', MockedReceiver) +@mock.patch( + 'inventory_provider.tasks.monitor.app.connection', mocked_connection) +@mock.patch( + 'inventory_provider.tasks.monitor.app.events.Receiver', MockedReceiver) def test_latchdb(data_config_filename, mocked_redis): os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'] = data_config_filename