def test_start_already_started(self): """Test start method already started.""" obj = TaskManager() with mock.patch.object(obj.logger, "debug") as debug_mock: obj._stopped = False obj.start() debug_mock.assert_called_once() obj.stop()
def test_enqueue_task_positive(self): """Test enqueue_task method positive result.""" obj = TaskManager() func = mock.Mock() obj._stopped = False obj._pool = mock.Mock() obj._pool.apply_async = mock.Mock(return_value="async_result") obj.enqueue_task(func) obj._pool.apply_async.assert_called_once()
def test_start_lazy_pool_start(self): """Test start method with lazy pool start.""" obj = TaskManager(is_lazy_pool_start=False) with mock.patch.object(obj.logger, "debug") as debug_mock: obj.start() obj._stopped = True obj.start() debug_mock.assert_called_with("Pool was already started!") obj.start()
def test_start_already_started(self, debug_mock): """Test start method already started.""" obj = TaskManager() obj._stopped = False obj.start() debug_mock.assert_called_once()