1313# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
1414import time
1515from typing import List
16+ from unittest .mock import patch
1617
1718import pytest
1819
@@ -102,7 +103,11 @@ async def test_graceful_shutdown_one_second_timeout():
102103
103104
104105@pytest .mark .asyncio
105- async def test_get_dep_tasks_info ():
106+ @patch ('camel.tasks.task.Task.decompose' )
107+ @patch (
108+ 'camel.societies.workforce.single_agent_worker.SingleAgentWorker._process_task'
109+ )
110+ async def test_get_dep_tasks_info (mock_process_task , mock_decompose ):
106111 """Original test for backwards compatibility."""
107112 sys_msg = BaseMessage .make_assistant_message (
108113 role_name = "programmer" ,
@@ -115,7 +120,18 @@ async def test_get_dep_tasks_info():
115120 id = '0' ,
116121 )
117122
118- subtasks = human_task .decompose (agent ) # TODO: use MagicMock
119- await test_worker ._process_task (
120- human_task , subtasks
121- ) # TODO: use MagicMock
123+ # Configure the mocks
124+ mock_subtasks = [
125+ Task (content = "Task 1" , id = "1" ),
126+ Task (content = "Task 2" , id = "2" ),
127+ ]
128+ mock_decompose .return_value = mock_subtasks
129+ mock_process_task .return_value = TaskState .DONE
130+
131+ # Execute the test
132+ subtasks = human_task .decompose (agent )
133+ await test_worker ._process_task (human_task , subtasks )
134+
135+ # Verify the mocks were called
136+ mock_decompose .assert_called_once_with (agent )
137+ mock_process_task .assert_called_once_with (human_task , mock_subtasks )
0 commit comments