Esempio n. 1
0
 def setUp(self):
     super(RunnerTest, self).setUp()
     self.fake_process = type("FakeProcess", (object,), {})()
     self.fake_process = Mock()
     self.fake_container = type("FakeContainer", (object,), {})()
     self.fake_container.config = {}
     self.fake_process_constructor = Mock(return_value=self.fake_process)
     MonkeyPatcher.patch(multiprocessing, "Process", self.fake_process_constructor)
     self.runner = Runner(self.fake_container)
Esempio n. 2
0
 def setUp(self):
     super(RunnerTest, self).setUp()
     self.fake_process = type("FakeProcess", (object, ), {})()
     self.fake_process = Mock()
     self.fake_container = type("FakeContainer", (object, ), {})()
     self.fake_container.config = {}
     self.fake_process_constructor = Mock(return_value=self.fake_process)
     MonkeyPatcher.patch(multiprocessing, "Process",
                         self.fake_process_constructor)
     self.runner = Runner(self.fake_container)
Esempio n. 3
0
 def test_update_search_index(self):
     container = type("FakeContainer", (object,), {})()
     container.search_updater = type("FakeSearchUpdater", (object,), {})()
     container.search_updater.run = Mock()
     _create_container = Mock(return_value=container)
     MonkeyPatcher.patch(utils, "_create_container", _create_container)
     fake_config = {"fake": "blah"}
     utils.update_search_index(fake_config)
     _create_container.assert_called_with(fake_config)
     self.assertTrue(container.search_updater.run.called)
Esempio n. 4
0
 def setup_storage(self):
     """
         This is important for comparing metadata later
         on because we "assertEqual" but the date would
         be different every time the test was run.  The
         solution was to patch _to_utc to always return
         the same date.
     """
     get_created_date = Mock(return_value=meta_utils.CREATED_DATE)
     MonkeyPatcher.patch(Initializer, "_get_created_date", get_created_date)
Esempio n. 5
0
 def setup_storage(self):
     """
         This is important for comparing metadata later
         on because we "assertEqual" but the date would
         be different every time the test was run.  The
         solution was to patch _to_utc to always return
         the same date.
     """
     get_created_date = Mock(return_value=meta_utils.CREATED_DATE)
     MonkeyPatcher.patch(Initializer, "_get_created_date", get_created_date)
Esempio n. 6
0
 def test_update_search_index(self):
     container = type("FakeContainer", (object, ), {})()
     container.search_updater = type("FakeSearchUpdater", (object, ), {})()
     container.search_updater.run = Mock()
     _create_container = Mock(return_value=container)
     MonkeyPatcher.patch(utils, "_create_container", _create_container)
     fake_config = {"fake": "blah"}
     utils.update_search_index(fake_config)
     _create_container.assert_called_with(fake_config)
     self.assertTrue(container.search_updater.run.called)
Esempio n. 7
0
 def mock_configure_logger(self):
     logger = logging.getLogger()
     configure_file_logger = Mock(return_value=logger)
     MonkeyPatcher.patch(background_utils, "configure_file_logger", configure_file_logger)
     return configure_file_logger
Esempio n. 8
0
 def setUp(self):
     super(UtilsTest, self).setUp()
     self.run_process_mock = Mock()
     MonkeyPatcher.patch(Runner, "_run_process", self.run_process_mock)
Esempio n. 9
0
 def setUp(self):
     super(UtilsTest, self).setUp()
     self.run_process_mock = Mock()
     MonkeyPatcher.patch(Runner, "_run_process", self.run_process_mock)
Esempio n. 10
0
 def mock_configure_logger(self):
     logger = logging.getLogger()
     configure_file_logger = Mock(return_value=logger)
     MonkeyPatcher.patch(background_utils, "configure_file_logger",
                         configure_file_logger)
     return configure_file_logger