test_print_next_cli.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
2 days ago
| 1 | """Integration — ``ok next`` + ``governance-sync --print-next`` (§ONS.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from cli.commands.next import EXIT_NEXT_MALFORMED |
| 8 | from cli.kit_root import kit_root |
| 9 | from tests.support import FIXTURES, git_status_runner, run_cli, write_config |
| 10 | from tools.print_next.extract import CURRENT_NEXT_HEADING |
| 11 | |
| 12 | |
| 13 | def _seed(tmp_path: Path) -> Path: |
| 14 | write_config(tmp_path, "config-git-only.yaml") |
| 15 | docs = tmp_path / "docs" |
| 16 | docs.mkdir(parents=True, exist_ok=True) |
| 17 | handover = docs / "OVERSEER-HANDOVER.md" |
| 18 | handover.write_text( |
| 19 | (FIXTURES / "print-next-handover.md").read_text(encoding="utf-8"), |
| 20 | encoding="utf-8", |
| 21 | ) |
| 22 | (docs / "ROADMAP.md").write_text("# Roadmap\n", encoding="utf-8") |
| 23 | return handover |
| 24 | |
| 25 | |
| 26 | def test_ok_next_exit_zero_heading_model(tmp_path: Path, capsys) -> None: |
| 27 | _seed(tmp_path) |
| 28 | runner = git_status_runner() |
| 29 | code = run_cli(["next"], cwd=tmp_path, runner=runner, kit=kit_root()) |
| 30 | out = capsys.readouterr().out |
| 31 | assert code == 0 |
| 32 | assert CURRENT_NEXT_HEADING in out |
| 33 | assert "Model:" in out |
| 34 | joined = " ".join(cmd for cmd, _cwd in runner.calls) |
| 35 | assert "muse" not in joined |
| 36 | assert "git" not in joined |
| 37 | |
| 38 | |
| 39 | def test_print_next_synonym_same_stdout(tmp_path: Path, capsys) -> None: |
| 40 | _seed(tmp_path) |
| 41 | runner = git_status_runner() |
| 42 | code_a = run_cli(["next"], cwd=tmp_path, runner=runner, kit=kit_root()) |
| 43 | out_a = capsys.readouterr().out |
| 44 | code_b = run_cli( |
| 45 | ["governance-sync", "--print-next"], |
| 46 | cwd=tmp_path, |
| 47 | runner=runner, |
| 48 | kit=kit_root(), |
| 49 | ) |
| 50 | out_b = capsys.readouterr().out |
| 51 | assert code_a == 0 |
| 52 | assert code_b == 0 |
| 53 | assert out_a == out_b |
| 54 | |
| 55 | |
| 56 | def test_print_next_write_exclusive(tmp_path: Path, capsys) -> None: |
| 57 | _seed(tmp_path) |
| 58 | code = run_cli( |
| 59 | ["governance-sync", "--print-next", "--write"], |
| 60 | cwd=tmp_path, |
| 61 | runner=git_status_runner(), |
| 62 | kit=kit_root(), |
| 63 | ) |
| 64 | err = capsys.readouterr().err |
| 65 | assert code == 2 |
| 66 | assert "print-next mutually exclusive with --write" in err |
| 67 | |
| 68 | |
| 69 | def test_print_next_all_lanes_exclusive(tmp_path: Path, capsys) -> None: |
| 70 | _seed(tmp_path) |
| 71 | code = run_cli( |
| 72 | ["governance-sync", "--print-next", "--all-lanes"], |
| 73 | cwd=tmp_path, |
| 74 | runner=git_status_runner(), |
| 75 | kit=kit_root(), |
| 76 | ) |
| 77 | err = capsys.readouterr().err |
| 78 | assert code == 2 |
| 79 | assert "print-next mutually exclusive with --all-lanes" in err |
| 80 | |
| 81 | |
| 82 | def test_malformed_exit_37(tmp_path: Path) -> None: |
| 83 | write_config(tmp_path, "config-git-only.yaml") |
| 84 | (tmp_path / "docs").mkdir(parents=True, exist_ok=True) |
| 85 | (tmp_path / "docs" / "OVERSEER-HANDOVER.md").write_text("# empty\n", encoding="utf-8") |
| 86 | code = run_cli(["next"], cwd=tmp_path, runner=git_status_runner(), kit=kit_root()) |
| 87 | assert code == EXIT_NEXT_MALFORMED |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
2 days ago