def test_new_task_executor_error(self): task_executor_factory = domain.TaskExecutorFactory( self.task_repo, self.image_repo, self.image_factory) context = mock.Mock() with mock.patch.object(oslo_utils.importutils, 'import_class') as mock_import_class: mock_import_class.side_effect = ImportError self.assertRaises(ImportError, task_executor_factory.new_task_executor, context)
def test_new_task_eventlet_backwards_compatibility(self): context = mock.MagicMock() self.config(task_executor='eventlet', group='task') task_executor_factory = domain.TaskExecutorFactory( self.task_repo, self.image_repo, self.image_factory) # NOTE(flaper87): "eventlet" executor. short name to avoid > 79. te_evnt = task_executor_factory.new_task_executor(context) self.assertIsInstance(te_evnt, taskflow_executor.TaskExecutor)
def test_new_task_executor(self): task_executor_factory = domain.TaskExecutorFactory( self.task_repo, self.image_repo, self.image_factory) context = mock.Mock() with mock.patch.object(oslo_utils.importutils, 'import_class') as mock_import_class: mock_executor = mock.Mock() mock_import_class.return_value = mock_executor task_executor_factory.new_task_executor(context) mock_executor.assert_called_once_with(context, self.task_repo, self.image_repo, self.image_factory)
def test_init(self): task_executor_factory = domain.TaskExecutorFactory(self.task_repo, self.image_repo, self.image_factory) self.assertEqual(self.task_repo, task_executor_factory.task_repo)