diff --git a/backend/SC4SNMP_UI_backend/common/inventory_utils.py b/backend/SC4SNMP_UI_backend/common/inventory_utils.py index 58adb30..853a234 100644 --- a/backend/SC4SNMP_UI_backend/common/inventory_utils.py +++ b/backend/SC4SNMP_UI_backend/common/inventory_utils.py @@ -29,7 +29,7 @@ def update_profiles_in_inventory(profile_to_search: str, process_record: Callabl :param kwargs: additional variables which user can pass to process_record function :return: """ - inventory_records = list(mongo_inventory.find({"profiles": {"$regex": f'.*{profile_to_search}.*'}})) + inventory_records = list(mongo_inventory.find({"profiles": {"$regex": f'.*{profile_to_search}.*'}, "delete": False})) for record in inventory_records: record_id = record["_id"] record_updated = inventory_conversion.backend2ui(record, inventory_type=None) # inventory_type isn't used diff --git a/backend/tests/ui_handling/post_endpoints/test_post_profiles.py b/backend/tests/ui_handling/post_endpoints/test_post_profiles.py index 3c5ce56..e2d1388 100644 --- a/backend/tests/ui_handling/post_endpoints/test_post_profiles.py +++ b/backend/tests/ui_handling/post_endpoints/test_post_profiles.py @@ -113,7 +113,7 @@ def test_delete_profile_record(m_update, m_delete, m_find, client): response = client.post(f'/profiles/delete/{common_id}') - calls = [call({'_id': ObjectId(common_id)}, {"_id": 0}), call({"profiles": {"$regex": '.*profile_1.*'}})] + calls = [call({'_id': ObjectId(common_id)}, {"_id": 0}), call({"profiles": {"$regex": '.*profile_1.*'}, "delete": False})] m_find.assert_has_calls(calls) assert m_delete.call_args == call({"_id": ObjectId(common_id)}) assert m_update.call_args == call({"_id": ObjectId(common_id)}, {"$set": backend_inventory_update}) @@ -232,7 +232,7 @@ def test_update_profile_record_with_name_change_success(m_find, m_update, client calls_find = [call({f"profile_1_edit": {"$exists": True}, "_id": {"$ne": ObjectId(common_id)}}), call({'_id': ObjectId(common_id)}, {"_id": 0}), - call({"profiles": {"$regex": '.*profile_1.*'}})] + call({"profiles": {"$regex": '.*profile_1.*'}, "delete": False})] calls_update = [call({'_id': ObjectId(common_id)}, {"$rename": {"profile_1": "profile_1_edit"}}), call({"_id": ObjectId(common_id)}, {"$set": backend_inventory_update}),