reuse-surface/tests/test_registry.py

58 lines
1.5 KiB
Python
Raw Permalink Normal View History

from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
return subprocess.run(
[sys.executable, "-m", "reuse_surface.cli", *args],
cwd=ROOT,
capture_output=True,
text=True,
check=False,
)
def test_validate_passes():
result = run_cli("validate")
assert result.returncode == 0
assert "ok: validated" in result.stdout
def test_validate_relations_clean():
result = run_cli("validate", "--relations", "--fail-on-warnings")
assert result.returncode == 0, result.stderr
def test_query_finds_registry():
result = run_cli("query", "--tag", "registry")
assert result.returncode == 0
assert "capability.registry.register" in result.stdout
def test_federation_compose():
result = run_cli("federation", "compose")
assert result.returncode == 0
assert (ROOT / "registry/indexes/federated.yaml").exists()
def test_export_json():
result = run_cli("export", "--format", "json")
assert result.returncode == 0
assert '"capabilities"' in result.stdout
def test_graph_check_clean():
result = run_cli("graph", "--check", "--fail-on-warnings")
assert result.returncode == 0, result.stderr
def test_catalog_writes_search():
result = run_cli("catalog")
assert result.returncode == 0
assert (ROOT / "docs/catalog/registry.json").exists()
assert (ROOT / "docs/catalog/search.html").exists()