refactor: install-service deprecated alias now forwards to service_install()

This commit is contained in:
Brian Krabach
2026-03-31 17:05:43 -07:00
parent ff2abb5f77
commit 496c37a32f
2 changed files with 25 additions and 10 deletions
+4 -2
View File
@@ -742,11 +742,13 @@ def main() -> None:
if args.command == "install-service": if args.command == "install-service":
print( print(
"Warning: 'install-service' is deprecated and will be removed in a future version." "\u26a0 'muxplex install-service' is deprecated."
" Use 'muxplex service install' instead.", " Use 'muxplex service install' instead.",
file=sys.stderr, file=sys.stderr,
) )
install_service(system=args.system) from muxplex.service import service_install # noqa: PLC0415
service_install()
elif args.command == "show-password": elif args.command == "show-password":
show_password() show_password()
elif args.command == "reset-secret": elif args.command == "reset-secret":
+21 -8
View File
@@ -73,23 +73,23 @@ def test_main_passes_session_ttl_flag():
def test_main_install_service_subcommand(): def test_main_install_service_subcommand():
"""main() with 'install-service' must invoke install_service().""" """main() with 'install-service' must invoke service_install() (new module)."""
from muxplex.cli import main from muxplex.cli import main
with patch("muxplex.cli.install_service") as mock_install: with patch("muxplex.service.service_install") as mock_install:
with patch("sys.argv", ["muxplex", "install-service"]): with patch("sys.argv", ["muxplex", "install-service"]):
main() main()
mock_install.assert_called_once_with(system=False) mock_install.assert_called_once()
def test_main_install_service_system_flag(): def test_main_install_service_system_flag():
"""main() with 'install-service --system' passes system=True.""" """main() with 'install-service --system' still calls service_install() (--system ignored; new module auto-detects)."""
from muxplex.cli import main from muxplex.cli import main
with patch("muxplex.cli.install_service") as mock_install: with patch("muxplex.service.service_install") as mock_install:
with patch("sys.argv", ["muxplex", "install-service", "--system"]): with patch("sys.argv", ["muxplex", "install-service", "--system"]):
main() main()
mock_install.assert_called_once_with(system=True) mock_install.assert_called_once()
def test_install_service_user_mode_writes_unit_file(tmp_path, monkeypatch): def test_install_service_user_mode_writes_unit_file(tmp_path, monkeypatch):
@@ -476,7 +476,7 @@ def test_main_check_dependencies_not_called_for_install_service(monkeypatch):
calls = [] calls = []
monkeypatch.setattr("muxplex.cli._check_dependencies", lambda: calls.append(True)) monkeypatch.setattr("muxplex.cli._check_dependencies", lambda: calls.append(True))
with patch("muxplex.cli.install_service"): with patch("muxplex.service.service_install"):
with patch("sys.argv", ["muxplex", "install-service"]): with patch("sys.argv", ["muxplex", "install-service"]):
main() main()
@@ -973,7 +973,7 @@ def test_install_service_subcommand_prints_deprecation_warning(capsys):
"""'muxplex install-service' must print a deprecation warning to stderr.""" """'muxplex install-service' must print a deprecation warning to stderr."""
from muxplex.cli import main from muxplex.cli import main
with patch("muxplex.cli.install_service"): with patch("muxplex.service.service_install"):
with patch("sys.argv", ["muxplex", "install-service"]): with patch("sys.argv", ["muxplex", "install-service"]):
main() main()
@@ -1102,6 +1102,19 @@ def test_service_logs_dispatches():
mock_fn.assert_called_once() mock_fn.assert_called_once()
def test_install_service_deprecated_calls_service_install(capsys):
"""'muxplex install-service' deprecated alias must call service_install() and print deprecation warning."""
from muxplex.cli import main
with patch("muxplex.service.service_install") as mock_service_install:
with patch("sys.argv", ["muxplex", "install-service"]):
main()
mock_service_install.assert_called_once()
captured = capsys.readouterr()
assert "deprecated" in captured.err.lower()
def test_service_subcommand_in_help(): def test_service_subcommand_in_help():
"""'service' must appear in muxplex --help output.""" """'service' must appear in muxplex --help output."""
import io import io