Private
Public Access
0
0

test(fix): Update tests to route config through AppController/env var

Four test files had patches/monkeypatches that referenced the
removed src.models.load_config or src.models.CONFIG_PATH module
constant. These all stem from the config I/O refactor (commit
7bcb5a8c) that renamed load_config/save_config to private I/O
primitives.

- tests/test_external_editor_gui.py: 2 sites changed from
  monkeypatch.setattr(models_module, 'load_config', ...) to
  monkeypatch.setattr('src.app_controller.AppController.load_config', ...)
- tests/test_external_mcp_e2e.py: CONFIG_PATH monkeypatch changed
  to SLOP_CONFIG env var (the only supported override path)
- tests/test_log_management_ui.py: same CONFIG_PATH -> SLOP_CONFIG fix
- tests/test_gen_send_empty_context.py: _StubController now receives
  ui_selected_context_files and _pending_generation_action from the
  app_instance BEFORE being assigned as controller (App.__getattr__
  delegates to controller, so attrs must be on the stub first)

Also: deleted tests/artifacts/manualslop_layout.ini (gitignored
stale file from March 4 referencing pre-refactor window names like
"Projects"/"Files"/"Screenshots" that no longer exist in the code).
Repo-root manualslop_layout.ini still references the same old
window names; user should run the existing "Reset Layout" command
(or delete it manually) to regenerate with the current window
catalog (Context Hub / AI Settings Hub / Discussion Hub / etc.).

Verified: 13 targeted tests pass:
- test_external_editor_gui.py (5/5)
- test_external_mcp_e2e.py (1/1)
- test_log_management_ui.py (2/2)
- test_gen_send_empty_context.py (5/5)
This commit is contained in:
2026-06-07 21:21:38 -04:00
parent 7bcb5a8c07
commit 94cfb1b5ff
4 changed files with 6 additions and 6 deletions
+2 -4
View File
@@ -160,8 +160,7 @@ def test_patch_modal_shows_with_configured_editor(live_gui, monkeypatch):
if not client.wait_for_server(timeout=15):
pytest.skip("GUI server not available")
import src.models as models_module
monkeypatch.setattr(models_module, 'load_config', lambda: test_external_editor_config())
monkeypatch.setattr('src.app_controller.AppController.load_config', lambda: test_external_editor_config())
sample_patch = """--- a/test.py
+++ b/test.py
@@ -201,8 +200,7 @@ def test_button_click_is_received(live_gui, monkeypatch):
if not client.wait_for_server(timeout=15):
pytest.skip("GUI server not available")
import src.models as models_module
monkeypatch.setattr(models_module, 'load_config', lambda: test_external_editor_config())
monkeypatch.setattr('src.app_controller.AppController.load_config', lambda: test_external_editor_config())
sample_patch = """--- a/test.py
+++ b/test.py
+1 -1
View File
@@ -12,7 +12,7 @@ from src import models
async def test_external_mcp_e2e_refresh_and_call(tmp_path, monkeypatch):
# 1. Setup mock config and mock server script
config_file = tmp_path / "config.toml"
monkeypatch.setattr(models, "CONFIG_PATH", str(config_file))
monkeypatch.setenv("SLOP_CONFIG", str(config_file))
mock_script = Path("scripts/mock_mcp_server.py").absolute()
+2
View File
@@ -59,6 +59,8 @@ def test_gen_send_with_context_skips_warning(app_instance):
app_instance.ui_selected_context_files = {"some_file.py"}
app_instance._pending_generation_action = None
stub_ctrl = _StubController()
stub_ctrl.ui_selected_context_files = app_instance.ui_selected_context_files
stub_ctrl._pending_generation_action = app_instance._pending_generation_action
app_instance.controller = stub_ctrl
app_instance._handle_generate_send()
assert "generate" in stub_ctrl.calls
+1 -1
View File
@@ -31,7 +31,7 @@ history = []
@pytest.fixture
def app_instance(mock_config: Path, mock_project: Path, monkeypatch: pytest.MonkeyPatch) -> App:
monkeypatch.setattr("src.models.CONFIG_PATH", mock_config)
monkeypatch.setenv("SLOP_CONFIG", str(mock_config))
monkeypatch.setattr("src.gui_2.filedialog", MagicMock())
with patch("src.project_manager.load_project") as mock_load, \
patch("src.session_logger.open_session"), \