From 5b1a1928ac1978b65538fb9b3d7657fe5869da5c Mon Sep 17 00:00:00 2001 From: ajasnosz Date: Wed, 10 Apr 2024 10:51:09 +0200 Subject: [PATCH] chore: fix formatting --- splunk_connect_for_snmp/common/inventory_processor.py | 2 +- splunk_connect_for_snmp/inventory/loader.py | 8 ++------ test/common/test_inventory_processor.py | 11 ++++++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/splunk_connect_for_snmp/common/inventory_processor.py b/splunk_connect_for_snmp/common/inventory_processor.py index 872907b70..9206315e5 100644 --- a/splunk_connect_for_snmp/common/inventory_processor.py +++ b/splunk_connect_for_snmp/common/inventory_processor.py @@ -238,5 +238,5 @@ def return_walk_profile(self, runtime_profiles, inventory_profiles): # if there's more than one walk profile, we're choosing the last one on the list walk_profile = walk_profiles[-1] if not walk_profile: - walk_profile = 'WalkProfile' + walk_profile = "WalkProfile" return walk_profile diff --git a/splunk_connect_for_snmp/inventory/loader.py b/splunk_connect_for_snmp/inventory/loader.py index e03ddfbda..b8ad5ed35 100644 --- a/splunk_connect_for_snmp/inventory/loader.py +++ b/splunk_connect_for_snmp/inventory/loader.py @@ -183,12 +183,8 @@ def load(): new_groups = groups_manager.return_collection() inventory_ui_collection = mongo_client.sc4snmp.inventory_ui - inventory_processor = InventoryProcessor( - groups_manager, inventory_ui_collection - ) - inventory_record_manager = InventoryRecordManager( - mongo_client, periodic_obj - ) + inventory_processor = InventoryProcessor(groups_manager, inventory_ui_collection) + inventory_record_manager = InventoryRecordManager(mongo_client, periodic_obj) if CONFIG_FROM_MONGO: logger.info(f"Loading inventory from inventory_ui collection") else: diff --git a/test/common/test_inventory_processor.py b/test/common/test_inventory_processor.py index 5d6694ee4..c0e247ddf 100644 --- a/test/common/test_inventory_processor.py +++ b/test/common/test_inventory_processor.py @@ -1,7 +1,11 @@ +import logging +import pytest import os from unittest import TestCase, mock from unittest.mock import Mock, mock_open, patch +from _pytest.logging import caplog + from splunk_connect_for_snmp.common.inventory_processor import ( InventoryProcessor, InventoryRecordManager, @@ -18,7 +22,8 @@ 0.0.0.0,,2c,public,,,1805,solo_profile1,False,False 0.0.0.0,1161,2c,public,,,1805,solo_profile2,False,False""" - +#TODO: write new test for walkProfile and full walk with flag +@pytest.mark.usefixtures("caplog") class TestInventoryProcessor(TestCase): profiles = { "test5": {"frequency": 6, "varBinds": [["IP-MIB"]]}, @@ -224,6 +229,10 @@ def test_get_group_hosts(self): inventory_processor.inventory_records, group_object_returned ) + # @mock.patch( + # "splunk_connect_for_snmp.common.inventory_processor.ENABLE_FULL_WALK", + # True, + # ) def test_get_group_hosts_hostname(self): group_manager = Mock() logger = Mock()