71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from reyna_cli.cli import app
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_run_signed_python_invokes_bundle_with_python_and_forwards_args(tmp_path):
|
|
from reyna_cli.signed_launcher import run_signed_python
|
|
|
|
executable = tmp_path / "ReynaCLIHost"
|
|
executable.write_text("binary")
|
|
calls = []
|
|
|
|
def fake_run(args, **kwargs):
|
|
calls.append((args, kwargs))
|
|
return SimpleNamespace(returncode=17)
|
|
|
|
result = run_signed_python(["local-services", "speech", "generate", "hello"], executable=executable, runner=fake_run)
|
|
|
|
assert result == 17
|
|
assert calls == [(
|
|
[str(executable), "--python", "local-services", "speech", "generate", "hello"],
|
|
{"check": False},
|
|
)]
|
|
|
|
|
|
def test_run_signed_python_rejects_missing_bundle_executable(tmp_path):
|
|
from reyna_cli.signed_launcher import SignedLauncherError, run_signed_python
|
|
|
|
try:
|
|
run_signed_python(["doctor"], executable=tmp_path / "missing")
|
|
except SignedLauncherError as exc:
|
|
assert "signed Reyna CLI app executable" in str(exc)
|
|
else:
|
|
raise AssertionError("missing signed executable must fail")
|
|
|
|
|
|
def test_signed_command_forwards_unknown_arguments(monkeypatch):
|
|
from reyna_cli import signed_launcher
|
|
|
|
captured = {}
|
|
|
|
def fake_run(args):
|
|
captured["args"] = args
|
|
return 0
|
|
|
|
monkeypatch.setattr(signed_launcher, "run_signed_python", fake_run)
|
|
|
|
result = runner.invoke(app, ["signed", "local-services", "speech", "generate", "hello", "--voice", "Alex"])
|
|
|
|
assert result.exit_code == 0, result.stdout
|
|
assert captured["args"] == ["local-services", "speech", "generate", "hello", "--voice", "Alex"]
|
|
|
|
|
|
def test_signed_command_reports_missing_signed_bundle(monkeypatch):
|
|
from reyna_cli import signed_launcher
|
|
|
|
def fake_run(args):
|
|
raise signed_launcher.SignedLauncherError("signed Reyna CLI app executable is missing")
|
|
|
|
monkeypatch.setattr(signed_launcher, "run_signed_python", fake_run)
|
|
|
|
result = runner.invoke(app, ["signed", "doctor"])
|
|
|
|
assert result.exit_code == 1
|
|
assert "signed Reyna CLI app executable is missing" in result.stdout
|