diff options
author | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-28 07:06:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-08-28 07:06:52 +0000 |
commit | 834c0f5899a7823ce77453aae4add76245b794c6 (patch) | |
tree | 993acfaa6f2010e74ea6a3f73495714e1c8b917f /app/test/event_based_scan/test_event.py | |
parent | 23f0c36a014295988d5fcbf9f0bda0ae2cb54057 (diff) | |
parent | 2f9d5cf583b4b5dd635f386cb9ac07435bd44cc8 (diff) |
Merge "Heavily refactored all event based scans"
Diffstat (limited to 'app/test/event_based_scan/test_event.py')
-rw-r--r-- | app/test/event_based_scan/test_event.py | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/app/test/event_based_scan/test_event.py b/app/test/event_based_scan/test_event.py index e3e8ab9..745fc2b 100644 --- a/app/test/event_based_scan/test_event.py +++ b/app/test/event_based_scan/test_event.py @@ -7,49 +7,28 @@ # which accompanies this distribution, and is available at # # http://www.apache.org/licenses/LICENSE-2.0 # ############################################################################### -import re import unittest +from unittest.mock import patch, Mock -from discover.configuration import Configuration -from test.event_based_scan.config.test_config \ - import MONGODB_CONFIG, ENV_CONFIG, COLLECTION_CONFIG -from utils.inventory_mgr import InventoryMgr +from test.event_based_scan.test_data.test_config \ + import ENV_CONFIG, COLLECTION_CONFIG from utils.logging.console_logger import ConsoleLogger -from utils.mongo_access import MongoAccess class TestEvent(unittest.TestCase): def setUp(self): self.log = ConsoleLogger() - self.mongo_config = MONGODB_CONFIG self.env = ENV_CONFIG self.collection = COLLECTION_CONFIG - - MongoAccess.set_config_file(self.mongo_config) - self.conf = Configuration() - self.conf.use_env(self.env) - - self.inv = InventoryMgr() - self.inv.set_collections(self.collection) self.item_ids = [] - def set_item(self, document): - self.inv.set(document) - self.item_ids.append(document['id']) + self.inv_patcher = patch('discover.events.event_base.InventoryMgr') + self.inv_class = self.inv_patcher.start() + self.inv = self.inv_class.return_value - def assert_empty_by_id(self, object_id): - doc = self.inv.get_by_id(self.env, object_id) - self.assertIsNone(doc) + self.log_patcher = patch('discover.fetcher.FullLogger') + self.log_patcher.start() def tearDown(self): - for item_id in self.item_ids: - item = self.inv.get_by_id(self.env, item_id) - # delete children - if item: - regexp = re.compile('^{}/'.format(item['id_path'])) - self.inv.delete('inventory', {'id_path': {'$regex': regexp}}) - - # delete target item - self.inv.delete('inventory', {'id': item_id}) - item = self.inv.get_by_id(self.env, item_id) - self.assertIsNone(item) + self.inv_patcher.stop() + self.log_patcher.stop() |