9e07fac1db
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7 continued).
The previous migration commit (8f11340b) handled the
'from src.models import X' pattern (85 sites). This commit handles
the 'models.<moved_class>' attribute access pattern (44 sites in 20
files), which the __getattr__ shim previously supported.
The migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_models_attr.py
which:
1. For each 'models.<moved_class>' reference, replaces it with the
bare class name (e.g., 'models.MCPConfiguration' -> 'MCPConfiguration')
2. Adds the import 'from src.<destination> import <moved_class>' at
the top of the file (deduplicated if the import already exists)
3. Skips moved classes that the file already imports directly
The migration script inserts the import after the 'from __future__
import annotations' line if present; otherwise it adds the import
to the destination module's existing import block. Two files
required manual fixes because the script's regex didn't handle them:
- src/rag_engine.py: uses 'from src import models' (not 'from
src.models import X'); the class is accessed
via 'models.RAGConfig'. Replaced with a
direct 'from src.mcp_client import RAGConfig'
import and removed the 'from src import models'.
- tests/test_project_context_20260627.py: uses the parens-style
multi-line 'from src.models import (X, Y, Z)'.
Replaced with the parens-style direct import.
After this commit:
- 'models.MCPConfiguration', 'models.FileItem', 'models.Ticket', etc.
no longer work in src/ and tests/ (the AttributeError raises
because models.py no longer has the __getattr__ entries for
moved classes)
- All consumer files have direct imports of the moved classes
Total: 44 'models.<moved_class>' references rewritten across 20 files.
48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock, patch
|
|
from src import models
|
|
|
|
def test_gui_has_kill_button_method():
|
|
from src.gui_2 import App
|
|
assert hasattr(App, '_cb_kill_ticket'), "App must have _cb_kill_ticket method"
|
|
|
|
def test_render_ticket_queue_table_columns():
|
|
with patch("src.gui_2.imgui") as mock_imgui, \
|
|
patch("src.gui_2.imscope") as mock_imscope:
|
|
mock_imgui.begin_table.return_value = True
|
|
mock_imgui.table_setup_column = MagicMock()
|
|
mock_imgui.table_headers_row = MagicMock()
|
|
mock_imgui.table_next_row = MagicMock()
|
|
mock_imgui.table_next_column = MagicMock()
|
|
mock_imgui.button.return_value = False
|
|
mock_imgui.checkbox = MagicMock(return_value=(False, False))
|
|
mock_imgui.selectable = MagicMock(return_value=(False, False))
|
|
mock_imgui.begin_drag_drop_source = MagicMock(return_value=False)
|
|
mock_imgui.begin_drag_drop_target = MagicMock(return_value=False)
|
|
mock_imgui.text = MagicMock()
|
|
mock_imgui.end_table = MagicMock()
|
|
mock_imgui.begin_combo.return_value = False
|
|
mock_imgui.ComboFlags_.height_small = 0
|
|
mock_imgui.push_style_color = MagicMock()
|
|
mock_imgui.pop_style_color = MagicMock()
|
|
mock_imgui.same_line = MagicMock()
|
|
|
|
mock_imscope.window.return_value.__enter__.return_value = (True, True)
|
|
mock_imscope.child.return_value.__enter__.return_value = True
|
|
mock_imscope.table.return_value.__enter__.return_value = True
|
|
mock_imscope.tree_node_ex.return_value.__enter__.return_value = True
|
|
mock_imscope.tab_item.return_value.__enter__.return_value = (True, True)
|
|
mock_imscope.style_color.return_value.__enter__.return_value = None
|
|
mock_imscope.style_var.return_value.__enter__.return_value = None
|
|
from src.gui_2 import App, render_ticket_queue
|
|
app = App.__new__(App)
|
|
app.active_track = MagicMock()
|
|
app.active_tickets = [Ticket(id="T-001", description="Test task", priority="medium", status="in_progress")]
|
|
app.ui_selected_tickets = set()
|
|
app.ui_selected_ticket_id = None
|
|
app.controller = MagicMock()
|
|
app._push_mma_state_update = MagicMock()
|
|
app._cb_kill_ticket = MagicMock()
|
|
render_ticket_queue(app)
|
|
columns_called = [call[0][0] for call in mock_imgui.table_setup_column.call_args_list]
|
|
assert "Actions" in columns_called, f"Expected Actions column, got: {columns_called}" |