fix: test suite green after Phase 1 config refactor
This commit is contained in:
@@ -1158,10 +1158,14 @@ def test_delete_session_success(client, monkeypatch):
|
|||||||
assert data["name"] == "my-session"
|
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)."""
|
"""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
|
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"])
|
monkeypatch.setattr("muxplex.main.get_session_list", lambda: ["my-session"])
|
||||||
|
|
||||||
captured = []
|
captured = []
|
||||||
|
|||||||
@@ -329,7 +329,9 @@ def test_default_settings_include_serve_keys():
|
|||||||
assert DEFAULT_SETTINGS["auth"] == "pam", (
|
assert DEFAULT_SETTINGS["auth"] == "pam", (
|
||||||
f"auth default must be 'pam', got: {DEFAULT_SETTINGS['auth']!r}"
|
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, (
|
assert DEFAULT_SETTINGS["session_ttl"] == 604800, (
|
||||||
f"session_ttl default must be 604800, got: {DEFAULT_SETTINGS['session_ttl']!r}"
|
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():
|
def test_serve_keys_patchable():
|
||||||
"""patch_settings() must accept and persist serve config keys."""
|
"""patch_settings() must accept and persist serve config keys."""
|
||||||
result = patch_settings({"host": "0.0.0.0", "port": 9000, "auth": "none", "session_ttl": 3600})
|
result = patch_settings(
|
||||||
assert result["host"] == "0.0.0.0", f"patch_settings() must accept host, got: {result['host']!r}"
|
{"host": "0.0.0.0", "port": 9000, "auth": "none", "session_ttl": 3600}
|
||||||
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["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, (
|
assert result["session_ttl"] == 3600, (
|
||||||
f"patch_settings() must accept session_ttl, got: {result['session_ttl']!r}"
|
f"patch_settings() must accept session_ttl, got: {result['session_ttl']!r}"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user