Files
state-hub/tests/test_register_from_classification.py
tegwick 0949d4c0d8 feat(classification-spine): implement STATE-WP-0065 repo-anchored model
Replace the ad-hoc coordination-domain spine with the Repo Classification
Standard: 14 market domains, classification columns on managed_repos, and
workplans anchored by repo_id (topic_id optional).

- Add Alembic migration d8e9f0a1b2c3 with data backfill and workstream→workplan rename
- Add api/classification.py validation and register-from-classification tooling
- Expose workplan-first REST/MCP surface with legacy workstream aliases
- Add C-24 consistency rule and legacy domain frontmatter mapping
- Update dashboard repos page with category/capability/stake filters
- Update orientation docs; mark STATE-WP-0065 finished
2026-06-22 13:52:13 +02:00

71 lines
2.0 KiB
Python

"""Tests for register_from_classification CLI (STATE-WP-0065 P3)."""
from __future__ import annotations
import json
import subprocess
import sys
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parent.parent
SCRIPT = REPO_ROOT / "scripts" / "register_from_classification.py"
def test_cli_help():
result = subprocess.run(
[sys.executable, str(SCRIPT), "--help"],
capture_output=True,
text=True,
cwd=REPO_ROOT,
)
assert result.returncode == 0
assert "--repo-path" in result.stdout
assert "--bulk" in result.stdout
assert "--dry-run" in result.stdout
@pytest.mark.asyncio
async def test_dry_run_repo_path_state_hub():
sys.path.insert(0, str(REPO_ROOT))
from scripts.register_from_classification import run_registration
import argparse
args = argparse.Namespace(
repo_path=str(REPO_ROOT),
slug=None,
bulk=False,
dry_run=True,
api=False,
db=False,
api_base="http://127.0.0.1:8000",
json=False,
)
report = await run_registration(args)
counts = report.counts()
assert counts["invalid"] == 0
assert counts["registered"] + counts["updated"] + counts["skipped"] >= 1
assert any(r.slug == "state-hub" for r in report.results)
# Valid classification file is always parsed even when DB domains are absent.
assert not any("repo_classification block" in r.detail for r in report.results)
def test_json_report_shape():
result = subprocess.run(
[
sys.executable,
str(SCRIPT),
"--repo-path",
str(REPO_ROOT),
"--dry-run",
"--json",
],
capture_output=True,
text=True,
cwd=REPO_ROOT,
)
payload = json.loads(result.stdout)
assert payload["summary"]["invalid"] == 0
assert "summary" in payload
assert "results" in payload
assert set(payload["summary"]) == {"registered", "updated", "skipped", "invalid"}