Pytest suite with a tiny_client fixture, an ephemeral Ed25519 keypair fixture, and a threaded HTTPServer helper. Exercises cli dispatch, inspect (including excluded-path handling), build-manifest and sign against the real m2dev-client scripts, diff-remote via a local server, and the full release publish composite against a local rsync target.
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def _run(*args: str) -> subprocess.CompletedProcess:
|
|
return subprocess.run(
|
|
[sys.executable, "-m", "metin_release", *args],
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
|
|
def test_version_flag():
|
|
r = _run("--version")
|
|
assert r.returncode == 0
|
|
assert "metin-release" in r.stdout
|
|
|
|
|
|
def test_help_top_level():
|
|
r = _run("--help")
|
|
assert r.returncode == 0
|
|
assert "release" in r.stdout
|
|
|
|
|
|
def test_help_release_inspect():
|
|
r = _run("release", "inspect", "--help")
|
|
assert r.returncode == 0
|
|
assert "--source" in r.stdout
|
|
|
|
|
|
def test_unknown_subcommand_exits_nonzero():
|
|
r = _run("release", "does-not-exist")
|
|
assert r.returncode != 0
|
|
|
|
|
|
def test_inspect_json_output_is_pure_json(tmp_path):
|
|
(tmp_path / "Metin2.exe").write_text("x")
|
|
(tmp_path / "Metin2Launcher.exe").write_text("y")
|
|
r = _run("--json", "release", "inspect", "--source", str(tmp_path))
|
|
assert r.returncode == 0
|
|
envelope = json.loads(r.stdout) # must parse cleanly
|
|
assert envelope["ok"] is True
|
|
assert envelope["command"] == "release inspect"
|
|
assert envelope["stats"]["file_count"] == 2
|
|
|
|
|
|
def test_inspect_human_mode_emits_json_on_stdout_and_summary_on_stderr(tmp_path):
|
|
(tmp_path / "Metin2.exe").write_text("x")
|
|
r = _run("release", "inspect", "--source", str(tmp_path))
|
|
assert r.returncode == 0
|
|
envelope = json.loads(r.stdout)
|
|
assert envelope["ok"] is True
|
|
assert "release inspect" in r.stderr
|