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.
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock
|
|
import threading
|
|
import time
|
|
from src.multi_agent_conductor import ConductorEngine
|
|
from src.mma import Track
|
|
|
|
def test_conductor_engine_initializes_empty_worker_and_abort_dicts() -> None:
|
|
"""
|
|
|
|
|
|
Test that ConductorEngine correctly initializes _active_workers and _abort_events as empty dictionaries.
|
|
"""
|
|
# Mock the track object
|
|
mock_track = MagicMock(spec=Track)
|
|
mock_track.tickets = []
|
|
|
|
# Initialize ConductorEngine
|
|
engine = ConductorEngine(track=mock_track)
|
|
|
|
# Verify _active_workers and _abort_events are empty dictionaries
|
|
assert engine._active_workers == {}
|
|
assert engine._abort_events == {}
|
|
|
|
def test_kill_worker_sets_abort_and_joins_thread() -> None:
|
|
"""
|
|
|
|
|
|
Test kill_worker: mock a running thread in _active_workers, call kill_worker,
|
|
assert abort_event is set and thread is joined.
|
|
"""
|
|
mock_track = MagicMock(spec=Track)
|
|
mock_track.tickets = []
|
|
engine = ConductorEngine(track=mock_track)
|
|
|
|
ticket_id = "test-ticket"
|
|
abort_event = threading.Event()
|
|
engine._abort_events[ticket_id] = abort_event
|
|
|
|
# Create a thread that waits for the abort event
|
|
def worker():
|
|
"""
|
|
[C: tests/test_symbol_parsing.py:test_handle_generate_send_appends_definitions, tests/test_symbol_parsing.py:test_handle_generate_send_no_symbols]
|
|
"""
|
|
abort_event.wait(timeout=2.0)
|
|
|
|
thread = threading.Thread(target=worker)
|
|
thread.start()
|
|
|
|
with engine._workers_lock:
|
|
engine._active_workers[ticket_id] = thread
|
|
|
|
# Call kill_worker
|
|
engine.kill_worker(ticket_id)
|
|
|
|
# Assertions
|
|
assert abort_event.is_set()
|
|
assert not thread.is_alive()
|
|
with engine._workers_lock:
|
|
assert ticket_id not in engine._active_workers |