generated from coulomb/repo-seed
Implement REUSE-WP-0013 registry establish, update, and stats
Some checks failed
ci / validate-registry (push) Has been cancelled
Some checks failed
ci / validate-registry (push) Has been cancelled
Add stats, establish (scaffold, publish-check, discover), and update CLI commands with optional llm-connect bridge, validate --root for sibling repos, pytest coverage, and documentation for sibling registry onboarding.
This commit is contained in:
77
tests/test_establish.py
Normal file
77
tests/test_establish.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import yaml
|
||||
|
||||
from reuse_surface.establish import (
|
||||
discover_capabilities,
|
||||
publish_check,
|
||||
scaffold_registry,
|
||||
)
|
||||
from reuse_surface.registry import registry_paths
|
||||
|
||||
|
||||
def test_scaffold_creates_layout(tmp_path: Path):
|
||||
created = scaffold_registry(tmp_path, domain="helix_forge")
|
||||
paths = registry_paths(tmp_path)
|
||||
assert paths["index"] in created
|
||||
data = yaml.safe_load(paths["index"].read_text(encoding="utf-8"))
|
||||
assert data["capabilities"] == []
|
||||
assert data["domain"] == "helix_forge"
|
||||
|
||||
|
||||
def test_scaffold_refuses_existing_without_force(tmp_path: Path):
|
||||
scaffold_registry(tmp_path)
|
||||
try:
|
||||
scaffold_registry(tmp_path)
|
||||
raise AssertionError("expected ValueError")
|
||||
except ValueError as exc:
|
||||
assert "already exists" in str(exc)
|
||||
|
||||
|
||||
def test_publish_check_local_index(tmp_path: Path):
|
||||
scaffold_registry(tmp_path)
|
||||
result = publish_check(tmp_path)
|
||||
assert result["ok"] is True
|
||||
assert any(check["name"] == "local_index_yaml" for check in result["checks"])
|
||||
|
||||
|
||||
def test_publish_check_raw_url_fail(tmp_path: Path):
|
||||
with patch(
|
||||
"reuse_surface.establish._probe_raw_url",
|
||||
return_value={"ok": False, "status": 303, "content_type": "text/html"},
|
||||
):
|
||||
result = publish_check(
|
||||
tmp_path,
|
||||
raw_url="https://example.com/capabilities.yaml",
|
||||
)
|
||||
assert result["ok"] is False
|
||||
assert result.get("remediation")
|
||||
|
||||
|
||||
def test_discover_dry_run_mock_llm(tmp_path: Path):
|
||||
scaffold_registry(tmp_path)
|
||||
(tmp_path / "README.md").write_text("# Demo service\n", encoding="utf-8")
|
||||
draft = {
|
||||
"domain": "helix_forge",
|
||||
"capabilities": [
|
||||
{
|
||||
"id": "capability.demo.sample",
|
||||
"name": "Sample",
|
||||
"summary": "Sample capability.",
|
||||
"owner": "demo",
|
||||
"vector": "D2 / A0 / C0 / R0",
|
||||
"tags": ["demo"],
|
||||
"consumption_modes": ["informational"],
|
||||
"discovery_intent": "Enable demo planning.",
|
||||
}
|
||||
],
|
||||
}
|
||||
with patch(
|
||||
"reuse_surface.establish.request_registry_draft",
|
||||
return_value=draft,
|
||||
):
|
||||
result = discover_capabilities(tmp_path, dry_run=True, apply=False)
|
||||
assert result["draft"]["capabilities"][0]["id"] == "capability.demo.sample"
|
||||
Reference in New Issue
Block a user