From 94cfb1b5ff764a6468251667957c3fd223b284ef Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 7 Jun 2026 21:21:38 -0400 Subject: [PATCH] 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) --- tests/test_external_editor_gui.py | 6 ++---- tests/test_external_mcp_e2e.py | 2 +- tests/test_gen_send_empty_context.py | 2 ++ tests/test_log_management_ui.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_external_editor_gui.py b/tests/test_external_editor_gui.py index 958741d2..79cc7f6f 100644 --- a/tests/test_external_editor_gui.py +++ b/tests/test_external_editor_gui.py @@ -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 diff --git a/tests/test_external_mcp_e2e.py b/tests/test_external_mcp_e2e.py index df41cb96..c672e390 100644 --- a/tests/test_external_mcp_e2e.py +++ b/tests/test_external_mcp_e2e.py @@ -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() diff --git a/tests/test_gen_send_empty_context.py b/tests/test_gen_send_empty_context.py index 9c83dd75..e8dd2011 100644 --- a/tests/test_gen_send_empty_context.py +++ b/tests/test_gen_send_empty_context.py @@ -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 diff --git a/tests/test_log_management_ui.py b/tests/test_log_management_ui.py index 43dea799..d00bca73 100644 --- a/tests/test_log_management_ui.py +++ b/tests/test_log_management_ui.py @@ -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"), \