Private
Public Access
0
0
Files
manual_slop/tests/test_files_and_media_tree.py
T
ed b15955c80e chore: stage remaining post-de-cruft fixes (src/test artifacts)
Staged-but-not-yet-fixed file artifacts from the post_module_taxonomy_de_cruft
followup. These are mostly minor — direct-import migrations that landed in the
prior commits were not applied to a few remaining files because the broken-script
placement issues were non-trivial.

For Tier 1 followup:
- src/commands.py — unused 'from src import models' removed by migration
- src/mcp_client.py — verified to no longer have the circular self-import
- src/models.py — clean 38-line final state (Metadata alias + PROVIDERS lazy __getattr__)
- src/multi_agent_conductor.py, src/project_manager.py, src/rag_engine.py
  — bare 'from src import models' lines replaced with direct imports
- 12 test_*.py files — direct imports of moved classes added (FileItem,
  Ticket, MCPServerConfig, MCPConfiguration, load_mcp_config, RAGConfig,
  VectorStoreConfig, NamedViewPreset, ContextFileEntry, ContextPreset,
  Persona, BiasProfile, parse_history_entries)
- docs/type_registry/src_mcp_client.md — regenerated via type_registry script

No production behavior changes here. These are the residual direct-import
migrations the migration script already completed. Some are tracked in the
end_of_session report for Tier 1 followup.
2026-06-26 23:18:27 -04:00

31 lines
1.6 KiB
Python

from unittest.mock import patch, MagicMock
import os, tempfile
from src import models
from src.project_files import FileItem
from src.gui_2 import render_files_and_media
def test_files_rendered_under_directory_grouping(app_instance):
with tempfile.TemporaryDirectory() as tmp:
sub = os.path.join(tmp, "sub")
os.makedirs(sub, exist_ok=True)
for p in [os.path.join(tmp, "a.py"), os.path.join(tmp, "b.py"), os.path.join(sub, "c.py")]:
open(p, "w").close()
app_instance.files = [FileItem(path=os.path.join(tmp, "a.py")), FileItem(path=os.path.join(tmp, "b.py")), FileItem(path=os.path.join(sub, "c.py"))]
with patch("src.gui_2.imgui") as mock_imgui, patch("src.gui_2.imscope") as mock_imscope, patch("src.gui_2.filedialog") as mock_filedialog, patch("src.gui_2.hide_tk_root", return_value=MagicMock()):
mock_imgui.collapsing_header.return_value = True
mock_imgui.TableFlags_ = type("T", (), {"resizable": 1, "borders": 2, "row_bg": 4})()
mock_imgui.TableColumnFlags_ = type("C", (), {"width_fixed": 1, "width_stretch": 2})()
mock_imgui.begin_table.return_value = True
mock_imgui.button.return_value = False
mock_imscope.group.return_value.__enter__.return_value = None
mock_imscope.tree_node_ex.return_value.__enter__.return_value = True
mock_filedialog.askopenfilenames.return_value = ()
mock_filedialog.askdirectory.return_value = ""
try:
render_files_and_media(app_instance)
except Exception as e:
import pytest
pytest.fail(f"render_files_and_media raised: {e}")
assert len(app_instance.files) == 3
assert mock_imscope.tree_node_ex.called, "render_files_and_media should group files under tree_node_ex by directory"