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.
74 lines
2.2 KiB
Python
74 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from metin_release.commands import build_manifest
|
|
from metin_release.errors import ValidationError
|
|
from metin_release.workspace import Context
|
|
|
|
|
|
def _ctx(script: Path) -> Context:
|
|
return Context(make_manifest_script=script)
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not Path("/home/jann/metin/repos/m2dev-client/scripts/make-manifest.py").is_file(),
|
|
reason="real make-manifest.py not available",
|
|
)
|
|
def test_build_manifest_real_script(tiny_client: Path, tmp_path: Path, make_manifest_script: Path):
|
|
out = tmp_path / "manifest.json"
|
|
ctx = _ctx(make_manifest_script)
|
|
args = argparse.Namespace(
|
|
source=tiny_client,
|
|
version="2026.04.14-1",
|
|
out=out,
|
|
previous=None,
|
|
notes=None,
|
|
launcher="Metin2Launcher.exe",
|
|
created_at="2026-04-14T00:00:00Z",
|
|
)
|
|
result = build_manifest.run(ctx, args)
|
|
assert out.is_file()
|
|
manifest = json.loads(out.read_text())
|
|
assert manifest["version"] == "2026.04.14-1"
|
|
assert manifest["launcher"]["path"] == "Metin2Launcher.exe"
|
|
assert len(manifest["files"]) >= 3 # Metin2.exe, readme.txt, subdir/*
|
|
stats = result.data["stats"]
|
|
assert stats["file_count"] == len(manifest["files"]) + 1
|
|
assert stats["blob_count"] >= 1
|
|
assert stats["total_bytes"] > 0
|
|
|
|
|
|
def test_build_manifest_missing_script(tiny_client: Path, tmp_path: Path):
|
|
ctx = _ctx(tmp_path / "nope.py")
|
|
args = argparse.Namespace(
|
|
source=tiny_client,
|
|
version="v1",
|
|
out=tmp_path / "manifest.json",
|
|
previous=None,
|
|
notes=None,
|
|
launcher="Metin2Launcher.exe",
|
|
created_at=None,
|
|
)
|
|
with pytest.raises(ValidationError):
|
|
build_manifest.run(ctx, args)
|
|
|
|
|
|
def test_build_manifest_missing_source(tmp_path: Path, make_manifest_script: Path):
|
|
ctx = _ctx(make_manifest_script)
|
|
args = argparse.Namespace(
|
|
source=tmp_path / "nope",
|
|
version="v1",
|
|
out=tmp_path / "manifest.json",
|
|
previous=None,
|
|
notes=None,
|
|
launcher="Metin2Launcher.exe",
|
|
created_at=None,
|
|
)
|
|
with pytest.raises(ValidationError):
|
|
build_manifest.run(ctx, args)
|