Private
Public Access
0
0
Files
manual_slop/tests/test_run_worker_lifecycle_abort.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

41 lines
1.3 KiB
Python

import unittest
from unittest.mock import MagicMock, patch
import threading
import json
import time
from src.multi_agent_conductor import run_worker_lifecycle
from src.models import Ticket, WorkerContext
class TestRunWorkerLifecycleAbort(unittest.TestCase):
def test_run_worker_lifecycle_returns_early_on_abort(self):
"""
Test that run_worker_lifecycle returns early and marks ticket as 'killed'
if the abort event is set for the ticket.
"""
# Mock ai_client.send
with patch('src.ai_client.send') as mock_send:
# Mock ticket and context
ticket = Ticket(id="T-001", description="Test task")
ticket = Ticket(id="T-001", description="Test task")
context = WorkerContext(ticket_id="T-001", model_name="test-model")
# Mock engine with _abort_events dict
mock_engine = MagicMock()
abort_event = threading.Event()
mock_engine._abort_events = {"T-001": abort_event}
# Set abort event
abort_event.set()
# Call run_worker_lifecycle
# md_content is expected to be passed if called like in ConductorEngine
run_worker_lifecycle(ticket, context, engine=mock_engine, md_content="test context")
# Assert ticket status is 'killed'
self.assertEqual(ticket.status, "killed")
# Also assert ai_client.send was NOT called (abort fires before the call)
mock_send.assert_not_called()
if __name__ == "__main__":
unittest.main()