Complete WP-0015: forgejo_hubs migration + closeout (T05/T07)
migrations/0007_forgejo_hubs.sql: table forgejo_hubs, auto-populated via a BEFORE INSERT trigger on phase_manifests that reads repo_hub/ repo_hub_uri straight out of the manifest JSONB (no top-level columns needed). ON CONFLICT DO NOTHING -- a hub already seen is left alone; correcting a URI is a SECURITY DEFINER governance action (correct_forgejo_hub_uri), not a plain UPDATE, matching every other governance-action pattern in this project. Thin Python wrappers added to registry.py. tests/test_forgejo_hubs.py (6 Docker-gated tests) and tests/test_reference_docs.py (13 tests, no Docker needed -- smoke-tests every real specs/policies/specs/profiles/ file, not just the two exercised incidentally by T03's Control Plane tests). All seven WP-0015 tasks done; workplan marked finished. Final suite: 94 passing offline, 183 passing under the service extras venv. No stray Docker containers left running. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
eaea89e125
commit
de308f8947
6 changed files with 419 additions and 5 deletions
71
tests/test_reference_docs.py
Normal file
71
tests/test_reference_docs.py
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
"""Smoke tests for WP-0015-T07: every real `specs/policies/`/
|
||||
`specs/profiles/` file must actually render without error. No database
|
||||
or Docker required — this only exercises `reference_docs.py`'s pure
|
||||
file-rendering logic.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from conftest import REPO_ROOT
|
||||
|
||||
pytest.importorskip("markdown")
|
||||
pytest.importorskip("yaml")
|
||||
|
||||
from target_revenue.service import reference_docs # noqa: E402
|
||||
|
||||
POLICY_SLUGS = ["linear-longstop-v0"]
|
||||
PROFILE_SLUGS = [
|
||||
"development-license",
|
||||
"cost-plus-operations",
|
||||
"phase-sponsorship",
|
||||
"service-with-development-allocation",
|
||||
"product-ideation",
|
||||
"general-consulting",
|
||||
]
|
||||
|
||||
|
||||
def test_all_real_policy_files_exist_on_disk():
|
||||
for slug in POLICY_SLUGS:
|
||||
assert (REPO_ROOT / "specs" / "policies" / f"{slug}.md").is_file()
|
||||
|
||||
|
||||
def test_all_real_profile_files_exist_on_disk():
|
||||
for slug in PROFILE_SLUGS:
|
||||
assert (REPO_ROOT / "specs" / "profiles" / f"{slug}.md").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", POLICY_SLUGS)
|
||||
def test_policy_doc_renders_without_error(slug):
|
||||
result = reference_docs.load_reference_doc("policies", slug)
|
||||
assert result is not None
|
||||
html, frontmatter = result
|
||||
assert "<h1>" in html or "<h2>" in html
|
||||
assert "policy_id" in frontmatter
|
||||
assert frontmatter["policy_id"].startswith("trsl:policy:")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slug", PROFILE_SLUGS)
|
||||
def test_profile_doc_renders_without_error(slug):
|
||||
result = reference_docs.load_reference_doc("profiles", slug)
|
||||
assert result is not None
|
||||
html, frontmatter = result
|
||||
assert "<h1>" in html
|
||||
assert "extension_id" in frontmatter
|
||||
assert frontmatter["extension_id"].startswith("trsl:extension:")
|
||||
|
||||
|
||||
def test_unknown_kind_returns_none():
|
||||
assert reference_docs.load_reference_doc("calculators", "anything") is None
|
||||
|
||||
|
||||
def test_unknown_slug_returns_none():
|
||||
assert reference_docs.load_reference_doc("policies", "does-not-exist") is None
|
||||
|
||||
|
||||
def test_policy_slug_from_id():
|
||||
assert reference_docs.policy_slug_from_id("trsl:policy:linear-longstop-v0@1.0") == "linear-longstop-v0"
|
||||
|
||||
|
||||
def test_extension_slug_from_id():
|
||||
assert reference_docs.extension_slug_from_id("trsl:extension:development-license@1.0") == "development-license"
|
||||
Loading…
Add table
Add a link
Reference in a new issue