test_governance_gates_surfaces.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """Integration tests for governance gate reminders on status + governance-sync.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from io import StringIO |
| 7 | from pathlib import Path |
| 8 | from unittest.mock import patch |
| 9 | |
| 10 | from cli.context import CliContext |
| 11 | from cli.main import main |
| 12 | from cli.output import OutputContext |
| 13 | from tests.support import FIXTURES, git_status_runner, make_runner, ok, run_cli, write_config |
| 14 | |
| 15 | |
| 16 | def _seed_gate_repo(tmp_path: Path) -> None: |
| 17 | write_config(tmp_path, "config-governance-gates.yaml") |
| 18 | overseer = tmp_path / ".overseer" |
| 19 | (overseer / "version.lock").write_text( |
| 20 | "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n" |
| 21 | "footprint_digest: sha256:0\ninstalled_at: '2026-01-01'\n" |
| 22 | "synced_at: '2026-01-01'\nfootprint: []\n", |
| 23 | encoding="utf-8", |
| 24 | ) |
| 25 | docs = tmp_path / "docs" |
| 26 | docs.mkdir(parents=True) |
| 27 | (docs / "ROADMAP.md").write_text( |
| 28 | (FIXTURES / "governance-gates-roadmap.md").read_text(encoding="utf-8"), |
| 29 | encoding="utf-8", |
| 30 | ) |
| 31 | (docs / "OVERSEER-HANDOVER.md").write_text( |
| 32 | (FIXTURES / "governance-gates-handover.md").read_text(encoding="utf-8"), |
| 33 | encoding="utf-8", |
| 34 | ) |
| 35 | (docs / "PHASE-DEMO-THINKING.md").write_text( |
| 36 | (FIXTURES / "governance-gates-phase-thinking.md").read_text(encoding="utf-8"), |
| 37 | encoding="utf-8", |
| 38 | ) |
| 39 | |
| 40 | |
| 41 | def test_status_json_includes_pending_governance_gates(tmp_path: Path) -> None: |
| 42 | _seed_gate_repo(tmp_path) |
| 43 | out = StringIO() |
| 44 | with patch("sys.stdout", out): |
| 45 | code = main( |
| 46 | ["status", "--json"], |
| 47 | ctx=CliContext.create( |
| 48 | cwd=tmp_path, |
| 49 | runner=git_status_runner(), |
| 50 | output=OutputContext(json_mode=True), |
| 51 | ), |
| 52 | ) |
| 53 | assert code == 0 |
| 54 | payload = json.loads(out.getvalue()) |
| 55 | assert "governance_gates" in payload |
| 56 | pending = payload["governance_gates"]["pending"] |
| 57 | assert any(item["gate_id"] == "build_verification" for item in pending) |
| 58 | |
| 59 | |
| 60 | def test_governance_sync_dry_run_appends_gate_footer(tmp_path: Path) -> None: |
| 61 | _seed_gate_repo(tmp_path) |
| 62 | runner = make_runner( |
| 63 | { |
| 64 | "git rev-parse --abbrev-ref HEAD": ok("main"), |
| 65 | "git status --porcelain": ok(""), |
| 66 | "git rev-parse origin/main": ok("cafebabe"), |
| 67 | "gh pr list --state merged --limit 5 --json number,title,mergeCommit,mergedAt": ok("[]"), |
| 68 | "git remote get-url origin": ok("[email protected]:owner/repo.git"), |
| 69 | } |
| 70 | ) |
| 71 | out = StringIO() |
| 72 | with patch("sys.stdout", out): |
| 73 | code = main( |
| 74 | ["governance-sync"], |
| 75 | ctx=CliContext.create(cwd=tmp_path, runner=runner), |
| 76 | ) |
| 77 | assert code == 0 |
| 78 | text = out.getvalue() |
| 79 | assert "Pending governance gates" in text or "governance-gates:" in text |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago