8f11340b38
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7). Each
'from src.models import X' for a moved class is rewritten to
'from src.<destination> import X':
Ticket, Track, WorkerContext, TrackState, TrackMetadata,
ThinkingSegment, EMPTY_TRACK_STATE -> src.mma
ProjectContext, ProjectMeta, ProjectOutput, ProjectFiles,
ProjectScreenshots, ProjectDiscussion, EMPTY_PROJECT_CONTEXT -> src.project
FileItem, Preset, ContextPreset, ContextFileEntry,
NamedViewPreset -> src.project_files
Tool, ToolPreset -> src.tool_presets
BiasProfile -> src.tool_bias
TextEditorConfig, ExternalEditorConfig,
EMPTY_TEXT_EDITOR_CONFIG -> src.external_editor
Persona -> src.personas
WorkspaceProfile -> src.workspace_manager
MCPServerConfig, MCPConfiguration, VectorStoreConfig,
RAGConfig, load_mcp_config -> src.mcp_client
NOT touched (kept on src.models; Phase 3 or Phase 4 will move them):
GenerateRequest, ConfirmRequest, DEFAULT_TOOL_CATEGORIES, Metadata, PROVIDERS
Migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_imports.py
which uses a class-to-module map and re.sub() to rewrite each
'from src.models import X' line.
Total: 85 import lines rewritten across 71 files.
Note: this commit depends on the v2 SHIPPED work
(origin/tier2/module_taxonomy_refactor_20260627) being merged into
this branch NEXT. On master (without the v2 SHIPPED commits), the
destination modules do not exist and these imports would fail.
41 lines
1.3 KiB
Python
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.mma 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() |