Private
Public Access
test(phase6_engine): mock send_result not send (Phase 2.16, pre-empts Phase 1.3 regression)
Phase 1.3 migrated src/multi_agent_conductor.py:591 (run_worker_lifecycle) to send_result(). The test_worker_streaming_intermediate test mocked src.ai_client.send, which would break once Phase 1.3 was applied. (Confirmed: test failed after Phase 1.3 commit.) Changes: - Replace patch(src.ai_client.send) with patch(src.ai_client.send_result) - Rename mock_send to mock_send_result - Wrap mock side_effect return with Result(data="DONE") - Add "from src.result_types import Result" import All 3 tests in test_phase6_engine.py pass.
This commit is contained in:
@@ -2,6 +2,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
from src.multi_agent_conductor import ConductorEngine, run_worker_lifecycle
|
from src.multi_agent_conductor import ConductorEngine, run_worker_lifecycle
|
||||||
from src.models import Ticket, Track, WorkerContext
|
from src.models import Ticket, Track, WorkerContext
|
||||||
from src import ai_client
|
from src import ai_client
|
||||||
|
from src.result_types import Result
|
||||||
|
|
||||||
def test_worker_streaming_intermediate():
|
def test_worker_streaming_intermediate():
|
||||||
ticket = Ticket(id="T-001", description="Test", status="todo", assigned_to="worker")
|
ticket = Ticket(id="T-001", description="Test", status="todo", assigned_to="worker")
|
||||||
@@ -9,7 +10,7 @@ def test_worker_streaming_intermediate():
|
|||||||
event_queue = MagicMock()
|
event_queue = MagicMock()
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch("src.ai_client.send") as mock_send,
|
patch("src.ai_client.send_result") as mock_send_result,
|
||||||
patch("src.multi_agent_conductor._queue_put") as mock_q_put,
|
patch("src.multi_agent_conductor._queue_put") as mock_q_put,
|
||||||
patch("src.multi_agent_conductor.confirm_spawn", return_value=(True, "p", "c")),
|
patch("src.multi_agent_conductor.confirm_spawn", return_value=(True, "p", "c")),
|
||||||
patch("src.ai_client.reset_session"),
|
patch("src.ai_client.reset_session"),
|
||||||
@@ -23,9 +24,9 @@ def test_worker_streaming_intermediate():
|
|||||||
if cb:
|
if cb:
|
||||||
cb({"kind": "tool_call", "payload": {"name": "test_tool", "script": "echo hello"}})
|
cb({"kind": "tool_call", "payload": {"name": "test_tool", "script": "echo hello"}})
|
||||||
cb({"kind": "tool_result", "payload": {"name": "test_tool", "output": "hello"}})
|
cb({"kind": "tool_result", "payload": {"name": "test_tool", "output": "hello"}})
|
||||||
return "DONE"
|
return Result(data="DONE")
|
||||||
|
|
||||||
mock_send.side_effect = side_effect
|
mock_send_result.side_effect = side_effect
|
||||||
run_worker_lifecycle(ticket, context, event_queue=event_queue)
|
run_worker_lifecycle(ticket, context, event_queue=event_queue)
|
||||||
|
|
||||||
# _queue_put(event_queue, event_name, payload)
|
# _queue_put(event_queue, event_name, payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user