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.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import pytest
|
|
from src.aggregate import group_files_by_dir, compute_file_stats
|
|
from src.project_files import FileItem
|
|
|
|
def test_group_files_by_dir():
|
|
files = [
|
|
FileItem(path="src/main.py"),
|
|
FileItem(path="src/utils/helpers.py"),
|
|
FileItem(path="tests/test_main.py"),
|
|
FileItem(path="README.md")
|
|
]
|
|
grouped = group_files_by_dir(files)
|
|
assert len(grouped) == 4
|
|
assert grouped["src"] == [files[0]]
|
|
assert grouped["src/utils"] == [files[1]]
|
|
assert grouped["tests"] == [files[2]]
|
|
assert grouped["."] == [files[3]]
|
|
|
|
def test_compute_file_stats():
|
|
import tempfile
|
|
import os
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
# Create a dummy python file
|
|
py_path = os.path.join(temp_dir, "test.py")
|
|
with open(py_path, "w") as f:
|
|
f.write("def foo():\n pass\n\nclass Bar:\n pass\n")
|
|
stats_result = compute_file_stats(py_path)
|
|
assert stats_result.ok, f"compute_file_stats failed: {stats_result.errors}"
|
|
stats = stats_result.data
|
|
assert stats["lines"] == 5
|
|
assert stats["ast_elements"] == 2 # 1 func, 1 class
|