Private
Public Access
0
0
Files
manual_slop/tests/test_phase6_engine.py
T
ed ada9617308 test(ai_client): rename send_result to send in 22 remaining test files
Batch rename of 22 test files. 62 references renamed total.

The full test suite is now GREEN again, matching the pre-rename baseline
from Task 1.1. Pure mechanical rename. No behavior change.

Files affected: test_ai_cache_tracking, test_ai_client_cli,
test_ai_client_result, test_api_events, test_context_pruner,
test_deepseek_provider, test_gemini_cli_* (3 files), test_gui2_mcp,
test_headless_* (2 files), test_live_gui_integration_v2,
test_orchestration_logic, test_phase6_engine, test_rag_integration,
test_run_worker_lifecycle_abort, test_spawn_interception_v2,
test_symbol_parsing, test_tier4_interceptor, test_tiered_aggregation,
test_token_usage.

Note: spec estimated 24 files; actual is 22 (test_deprecation_warnings
no longer exists, and 1 fewer file than spec's list).

Refs: conductor/tracks/send_result_to_send_20260616/
2026-06-17 00:38:29 -04:00

87 lines
3.3 KiB
Python

from unittest.mock import MagicMock, patch
from src.multi_agent_conductor import ConductorEngine, run_worker_lifecycle
from src.models import Ticket, Track, WorkerContext
from src import ai_client
from src.result_types import Result
def test_worker_streaming_intermediate():
ticket = Ticket(id="T-001", description="Test", status="todo", assigned_to="worker")
context = WorkerContext(ticket_id="T-001", model_name="test-model", messages=[])
event_queue = MagicMock()
with (
patch("src.ai_client.send") as mock_send,
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.ai_client.reset_session"),
patch("src.ai_client.set_provider"),
patch("src.ai_client.get_provider"),
patch("src.ai_client.get_comms_log", return_value=[])
):
def side_effect(*args, **kwargs):
cb = ai_client.comms_log_callback
if cb:
cb({"kind": "tool_call", "payload": {"name": "test_tool", "script": "echo hello"}})
cb({"kind": "tool_result", "payload": {"name": "test_tool", "output": "hello"}})
return Result(data="DONE")
mock_send.side_effect = side_effect
run_worker_lifecycle(ticket, context, event_queue=event_queue)
# _queue_put(event_queue, event_name, payload)
responses = [call.args[2] for call in mock_q_put.call_args_list if call.args[1] == "response"]
assert any("[TOOL CALL]" in r.get("text", "") for r in responses)
assert any("[TOOL RESULT]" in r.get("text", "") for r in responses)
def test_per_tier_model_persistence():
# Mock UI frameworks before importing gui_2
mock_imgui = MagicMock()
with patch.dict("sys.modules", {
"imgui_bundle": MagicMock(),
"imgui_bundle.imgui": mock_imgui,
"imgui_bundle.hello_imgui": MagicMock(),
"imgui_bundle.immapp": MagicMock(),
}):
from src.gui_2 import App
with (
patch("src.gui_2.project_manager.load_project", return_value={}),
patch("src.gui_2.project_manager.migrate_from_legacy_config", return_value={}),
patch("src.gui_2.project_manager.save_project"),
patch("src.app_controller.AppController.save_config"),
patch("src.gui_2.theme.load_from_config"),
patch("src.gui_2.ai_client.set_provider"),
patch("src.gui_2.ai_client.list_models", return_value=["gpt-4", "claude-3"]),
patch("src.performance_monitor.PerformanceMonitor"),
patch("src.gui_2.api_hooks.HookServer"),
patch("src.gui_2.session_logger.open_session"),
patch("src.gui_2.session_logger.reset_session")
):
app = App()
app.controller.available_models = ["gpt-4", "claude-3"]
tier = "Tier 3"
model = "claude-3"
# Simulate 'Tier Model Config' UI logic
app.controller.mma_tier_usage[tier]["model"] = model
app.controller.project.setdefault("mma", {}).setdefault("tier_models", {})[tier] = model
assert app.controller.project["mma"]["tier_models"][tier] == model
def test_retry_escalation():
# This test verifies the retry escalation logic works
# We test the core concept: when a ticket is blocked, retry_count should increment
ticket = Ticket(id="T-001", description="Test", status="todo", assigned_to="worker")
# Simulate what happens when a ticket gets blocked
ticket.status = "blocked"
ticket.retry_count += 1
assert ticket.status == "blocked"
assert ticket.retry_count == 1
# Verify escalation can happen
assert ticket.retry_count < 2 # Should be eligible for retry