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.
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
import pytest
|
|
from src.context_presets import ContextPresetManager
|
|
from src.project_files import ContextPreset, ContextFileEntry
|
|
|
|
def test_save_context_preset():
|
|
manager = ContextPresetManager()
|
|
project_dict = {}
|
|
preset_name = "test_preset"
|
|
files = [ContextFileEntry(path="file1.py"), ContextFileEntry(path="file2.py")]
|
|
screenshots = ["screenshot1.png"]
|
|
|
|
preset = ContextPreset(name=preset_name, files=files, screenshots=screenshots)
|
|
manager.save_preset(project_dict, preset)
|
|
|
|
assert "context_presets" in project_dict
|
|
assert preset_name in project_dict["context_presets"]
|
|
assert project_dict["context_presets"][preset_name]["files"] == [f.to_dict() for f in files]
|
|
assert project_dict["context_presets"][preset_name]["screenshots"] == screenshots
|
|
|
|
def test_load_all_context_presets():
|
|
manager = ContextPresetManager()
|
|
project_dict = {
|
|
"context_presets": {
|
|
"test_preset": {
|
|
"name": "test_preset",
|
|
"files": [{"path": "file1.py", "view_mode": "summary", "custom_slices": []}],
|
|
"screenshots": ["screenshot1.png"]
|
|
}
|
|
}
|
|
}
|
|
presets_result = manager.load_all(project_dict)
|
|
assert presets_result.ok, f"load_all failed: {presets_result.errors}"
|
|
presets = presets_result.data
|
|
|
|
assert "test_preset" in presets
|
|
assert presets["test_preset"].files[0].path == "file1.py"
|
|
assert presets["test_preset"].screenshots == ["screenshot1.png"]
|
|
|
|
|
|
def test_delete_context_preset():
|
|
manager = ContextPresetManager()
|
|
project_dict = {
|
|
"context_presets": {
|
|
"test_preset": {
|
|
"name": "test_preset",
|
|
"files": [{"path": "file1.py", "view_mode": "summary", "custom_slices": []}],
|
|
"screenshots": []
|
|
}
|
|
}
|
|
}
|
|
|
|
manager.delete_preset(project_dict, "test_preset")
|
|
|
|
assert "test_preset" not in project_dict["context_presets"]
|
|
|
|
def test_delete_nonexistent_preset_no_error():
|
|
manager = ContextPresetManager()
|
|
project_dict = {"context_presets": {}}
|
|
# Should not raise error if it doesn't exist
|
|
manager.delete_preset(project_dict, "nonexistent")
|
|
assert "nonexistent" not in project_dict["context_presets"]
|