예제 #1
0
 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()
예제 #2
0
 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()
예제 #3
0
 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()
예제 #4
0
 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()