def _set_stubs(self): self.mock_config = global_config.FakeGlobalConfig() self.god.stub_with(global_config, 'global_config', self.mock_config) self.mock_drone_manager = MockDroneManager() drone_manager._set_instance(self.mock_drone_manager) self.mock_email_manager = MockEmailManager() self.god.stub_with(email_manager, 'manager', self.mock_email_manager) self._database = ( database_connection.TranslatingDatabase.get_test_database( translators=scheduler_lib._DB_TRANSLATORS)) self._database.connect(db_type='django') self.god.stub_with(monitor_db, '_db', self._database) self.god.stub_with(scheduler_models, '_db', self._database) MockConnectionManager.db = self._database scheduler_lib.ConnectionManager = MockConnectionManager monitor_db.initialize_globals() scheduler_models.initialize_globals() patcher = mock.patch( 'autotest_lib.scheduler.luciferlib.is_lucifer_enabled', lambda: False) patcher.start() self.addCleanup(patcher.stop)
def _set_monitor_stubs(self): self.mock_config = global_config.FakeGlobalConfig() self.god.stub_with(global_config, 'global_config', self.mock_config) # Clear the instance cache as this is a brand new database. scheduler_models.DBObject._clear_instance_cache() self._database = ( database_connection.TranslatingDatabase.get_test_database( translators=scheduler_lib._DB_TRANSLATORS)) self._database.connect(db_type='django') self._database.debug = _DEBUG connection_manager = scheduler_lib.ConnectionManager(autocommit=False) self.god.stub_with(connection_manager, 'db_connection', self._database) self.god.stub_with(monitor_db, '_db_manager', connection_manager) self.god.stub_with(monitor_db, '_db', self._database) self.god.stub_with(monitor_db.BaseDispatcher, '_get_pending_queue_entries', self._get_pending_hqes) self.god.stub_with(scheduler_models, '_db', self._database) self.god.stub_with(drone_manager.instance(), '_results_dir', '/test/path') self.god.stub_with(drone_manager.instance(), '_temporary_directory', '/test/path/tmp') self.god.stub_with(drone_manager.instance(), 'initialize', lambda *args: None) self.god.stub_with(drone_manager.instance(), 'execute_actions', lambda *args: None) monitor_db.initialize_globals() scheduler_models.initialize_globals()