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.
63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
import pytest
|
|
from src.project_files import ContextPreset, ContextFileEntry
|
|
|
|
def test_context_file_entry_serialization():
|
|
p = ContextFileEntry(path="test.py", view_mode="skeleton")
|
|
d = p.to_dict()
|
|
# Check for default custom_slices
|
|
assert d == {"path": "test.py", "view_mode": "skeleton", "custom_slices": [], "ast_definitions": False, "ast_mask": {}, "ast_signatures": False}
|
|
|
|
p2 = ContextFileEntry.from_dict(d)
|
|
assert p2.path == "test.py"
|
|
assert p2.view_mode == "skeleton"
|
|
assert p2.custom_slices == []
|
|
|
|
# Test with custom_slices
|
|
p3 = ContextFileEntry(path="test.py", view_mode="summary", custom_slices=["1-10"])
|
|
d3 = p3.to_dict()
|
|
assert d3["custom_slices"] == ["1-10"]
|
|
p4 = ContextFileEntry.from_dict(d3)
|
|
assert p4.custom_slices == ["1-10"]
|
|
|
|
def test_context_preset_serialization():
|
|
f1 = ContextFileEntry(path="a.py", view_mode="full")
|
|
f2 = ContextFileEntry(path="b.py", view_mode="summary", custom_slices=["5-15"])
|
|
|
|
preset = ContextPreset(
|
|
name="test_preset",
|
|
files=[f1, f2],
|
|
screenshots=["shot1.png"],
|
|
description="Test description"
|
|
)
|
|
|
|
d = preset.to_dict()
|
|
assert len(d["files"]) == 2
|
|
assert d["files"][0]["path"] == "a.py"
|
|
assert d["files"][1]["custom_slices"] == ["5-15"]
|
|
assert d["screenshots"] == ["shot1.png"]
|
|
assert d["description"] == "Test description"
|
|
|
|
p2 = ContextPreset.from_dict("test_preset", d)
|
|
assert p2.name == "test_preset"
|
|
assert p2.description == "Test description"
|
|
assert len(p2.files) == 2
|
|
assert p2.files[0].view_mode == "full"
|
|
assert p2.files[1].custom_slices == ["5-15"]
|
|
assert p2.screenshots == ["shot1.png"]
|
|
|
|
def test_context_preset_from_dict_legacy():
|
|
# Test handling of legacy string paths in preset files and missing description/custom_slices
|
|
d = {
|
|
"files": ["legacy.py", {"path": "new.py", "view_mode": "skeleton"}],
|
|
"screenshots": []
|
|
}
|
|
preset = ContextPreset.from_dict("legacy_test", d)
|
|
assert len(preset.files) == 2
|
|
assert preset.files[0].path == "legacy.py"
|
|
assert preset.files[0].view_mode == "summary" # Default
|
|
assert preset.files[0].custom_slices == []
|
|
assert preset.files[1].path == "new.py"
|
|
assert preset.files[1].view_mode == "skeleton"
|
|
assert preset.files[1].custom_slices == []
|
|
assert preset.description == ""
|