From 8d465ad8a51bff11fb33b76100e1a2634fae9b63 Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Tue, 31 Mar 2026 14:50:22 -0700 Subject: [PATCH] fix: test suite green after Phase 1 config refactor --- muxplex/tests/test_api.py | 6 +++++- muxplex/tests/test_settings.py | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/muxplex/tests/test_api.py b/muxplex/tests/test_api.py index c40bc9a..f247555 100644 --- a/muxplex/tests/test_api.py +++ b/muxplex/tests/test_api.py @@ -1158,10 +1158,14 @@ def test_delete_session_success(client, monkeypatch): assert data["name"] == "my-session" -def test_delete_session_calls_kill_session(client, monkeypatch): +def test_delete_session_calls_kill_session(client, monkeypatch, tmp_path): """DELETE /api/sessions/{name} runs 'tmux kill-session -t {name}' via subprocess (default template).""" + import muxplex.settings as settings_mod from unittest.mock import MagicMock, patch + # Redirect settings to a non-existent path so the default template is used + monkeypatch.setattr(settings_mod, "SETTINGS_PATH", tmp_path / "no-settings.json") + monkeypatch.setattr("muxplex.main.get_session_list", lambda: ["my-session"]) captured = [] diff --git a/muxplex/tests/test_settings.py b/muxplex/tests/test_settings.py index 2bdd59a..11ef59c 100644 --- a/muxplex/tests/test_settings.py +++ b/muxplex/tests/test_settings.py @@ -329,7 +329,9 @@ def test_default_settings_include_serve_keys(): assert DEFAULT_SETTINGS["auth"] == "pam", ( f"auth default must be 'pam', got: {DEFAULT_SETTINGS['auth']!r}" ) - assert "session_ttl" in DEFAULT_SETTINGS, "DEFAULT_SETTINGS must include 'session_ttl'" + assert "session_ttl" in DEFAULT_SETTINGS, ( + "DEFAULT_SETTINGS must include 'session_ttl'" + ) assert DEFAULT_SETTINGS["session_ttl"] == 604800, ( f"session_ttl default must be 604800, got: {DEFAULT_SETTINGS['session_ttl']!r}" ) @@ -354,10 +356,18 @@ def test_load_settings_returns_serve_keys_when_file_missing(): def test_serve_keys_patchable(): """patch_settings() must accept and persist serve config keys.""" - result = patch_settings({"host": "0.0.0.0", "port": 9000, "auth": "none", "session_ttl": 3600}) - assert result["host"] == "0.0.0.0", f"patch_settings() must accept host, got: {result['host']!r}" - assert result["port"] == 9000, f"patch_settings() must accept port, got: {result['port']!r}" - assert result["auth"] == "none", f"patch_settings() must accept auth, got: {result['auth']!r}" + result = patch_settings( + {"host": "0.0.0.0", "port": 9000, "auth": "none", "session_ttl": 3600} + ) + assert result["host"] == "0.0.0.0", ( + f"patch_settings() must accept host, got: {result['host']!r}" + ) + assert result["port"] == 9000, ( + f"patch_settings() must accept port, got: {result['port']!r}" + ) + assert result["auth"] == "none", ( + f"patch_settings() must accept auth, got: {result['auth']!r}" + ) assert result["session_ttl"] == 3600, ( f"patch_settings() must accept session_ttl, got: {result['session_ttl']!r}" )