mirror of
https://github.com/spoopyghosty0/frameport.git
synced 2026-10-20 06:01:27 +02:00
Installing on the Frame restarted Steam to add the shortcuts, which also closed FramePort running there. Settings -> Installing gets a Steam library mode: now (as before; restarts also wait while FramePort runs on the Frame), later (no restart: Steam's next start re-applies and verifies the shortcuts through bounded steam.service hooks) or off (no shortcuts; Play starts the game from FramePort). Restart Steam now bypasses the holds and asks before ending a running game. Agent v99. Based on the feature branch's two commits (a311498,cf05ce2), merged onto main.
60 lines
2.2 KiB
Python
60 lines
2.2 KiB
Python
"""Command line: error output and exit codes."""
|
|
import pytest
|
|
|
|
|
|
def test_errors_are_one_line_on_stderr(monkeypatch, capsys):
|
|
from paramiko.ssh_exception import NoValidConnectionsError
|
|
|
|
from frameport import cli
|
|
|
|
def boom():
|
|
raise NoValidConnectionsError({("10.0.0.9", 22): OSError("refused")})
|
|
|
|
monkeypatch.delenv("FRAMEPORT_DEBUG", raising=False)
|
|
monkeypatch.setattr(cli, "app", boom)
|
|
with pytest.raises(SystemExit) as e:
|
|
cli.main()
|
|
err = capsys.readouterr().err
|
|
assert e.value.code == 1 and err.startswith("Error: Can't reach your Frame") and "Traceback" not in err
|
|
monkeypatch.setenv("FRAMEPORT_DEBUG", "1")
|
|
with pytest.raises(NoValidConnectionsError):
|
|
cli.main()
|
|
|
|
|
|
@pytest.mark.parametrize("mode", ["now", "later", "off"])
|
|
def test_steam_library_setting_cli(monkeypatch, mode):
|
|
from types import SimpleNamespace
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from frameport import cli
|
|
from frameport.core import library
|
|
|
|
calls = []
|
|
frame = SimpleNamespace(agent=lambda command, **kw: calls.append((command, kw)) or {})
|
|
monkeypatch.setattr(cli, "_target", lambda _: SimpleNamespace(connect=lambda: SimpleNamespace(frame=frame)))
|
|
result = CliRunner().invoke(cli.app, ["frame", "steam-library", mode])
|
|
assert result.exit_code == 0, result.output
|
|
assert library.setting("install.steam_library") == mode
|
|
assert calls == [("library_mode", {"mode": mode})]
|
|
|
|
|
|
def test_restart_steam_cli_confirmation(monkeypatch):
|
|
from types import SimpleNamespace
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from frameport import cli
|
|
|
|
calls = []
|
|
def agent(command, **kw):
|
|
calls.append(kw)
|
|
return {} if kw.get("confirm") else {"confirmation_required": True}
|
|
frame = SimpleNamespace(agent=agent)
|
|
monkeypatch.setattr(cli, "_target", lambda _: SimpleNamespace(connect=lambda: SimpleNamespace(frame=frame)))
|
|
result = CliRunner().invoke(cli.app, ["frame", "restart-steam"], input="n\n")
|
|
assert result.exit_code != 0 and calls == [{"confirm": False}]
|
|
calls.clear()
|
|
result = CliRunner().invoke(cli.app, ["frame", "restart-steam"], input="y\n")
|
|
assert result.exit_code == 0 and calls == [{"confirm": False}, {"confirm": True}]
|