"""Shared implementation-spec review fixtures; no test cases are declared here.""" import copy import importlib.util from .paths import ROOT MODPATH = ROOT / "harness/agents/spec/skills/gitea-implementation-spec-review/scripts/review_support.py" spec = importlib.util.spec_from_file_location("review_support", MODPATH) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) def result(verdict="approve"): return { "schema": "gitea-agent.implementation-spec-review-result/v1", "target": {"owner": "acme", "repository": "repo", "issue": 3, "pull": 7, "head": "a" * 40}, "contract_sha256": "b" * 64, "verdict": verdict, "criteria": [{"criterion": "REQ-1", "contract": "계약", "implementation_paths": ["src/a.py"], "test_paths": ["tests/test_a.py"], "evidence": "증거", "result": "satisfied", "reason": "충족"}], "scope": {"missing": [], "excess": [], "spec_conflicts": []}, "conclusion": "모든 기준을 충족했다.", } def publication_fixture(): r = result(); paths = {"src/a.py", "tests/test_a.py"} body = mod.render_review(r, paths, declaration={"mode": "none"}) url = "https://example.test/acme/repo/pulls/7" user = {"id": 42, "login": "spec-agent"} review = {"id": 11, "body": body, "commit_id": r["target"]["head"], "state": "APPROVED", "user": user, "official": True, "stale": False, "dismissed": False, "comments_count": 0, "submitted_at": "2026-10-03T01:24:00Z", "updated_at": "2026-10-03T01:24:00Z", "pull_request_url": url} before = {"issue": {"id": 3, "number": 3, "repository": {"full_name": "acme/repo"}, "updated_at": "2026-10-03T00:00:00Z", "title": "contract"}, "issue_comments": [], "pr": {"id": 7, "number": 7, "html_url": url, "url": url, "base": {"repo": {"full_name": "acme/repo"}, "sha": "c" * 40}, "head": {"sha": "a" * 40}, "user": {"id": 99}, "state": "open", "merged": False, "review_comments": 0, "updated_at": "2026-10-03T00:00:00Z", "requested_reviewers": []}, "pr_comments": [], "reviews": [], "timeline": [], "files": [{"filename": "src/a.py", "status": "modified", "additions": 1}]} after = copy.deepcopy(before); after["reviews"] = [review] after["pr"]["updated_at"] = review["submitted_at"]; after["pr"]["review_comments"] = 1 after["timeline"] = [{"id": 101, "review_id": 11, "user": user, "body": body, "type": "review", "created_at": review["submitted_at"], "updated_at": review["submitted_at"], "pull_request_url": url}] return before, after, review, r, paths def verify_fixture(before, after, review, r, paths, contract=None): return mod.verify_publication(before, after, review, r, paths, 42, [], contract, expected_pr_url="https://example.test/acme/repo/pulls/7")