test_verify_step_cycle.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
9 hours ago
| 1 | """End-to-end verify-step CLI tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | |
| 8 | import yaml |
| 9 | |
| 10 | from cli.kit_root import kit_root |
| 11 | from tests.support import CHECKPOINTS, git_status_runner, run_cli, seed_checkpoint_repo |
| 12 | |
| 13 | |
| 14 | def test_cli_step_pass_updates_manifest(tmp_path: Path, capsys) -> None: |
| 15 | seed_checkpoint_repo(tmp_path) |
| 16 | code = run_cli( |
| 17 | ["verify-step", "--step", "alpha", "--json"], |
| 18 | cwd=tmp_path, |
| 19 | runner=git_status_runner(), |
| 20 | kit=kit_root(), |
| 21 | json_mode=True, |
| 22 | ) |
| 23 | assert code == 0 |
| 24 | payload = json.loads(capsys.readouterr().out) |
| 25 | assert payload["ok"] is True |
| 26 | assert payload["dry_run"] is False |
| 27 | manifest = yaml.safe_load((tmp_path / "manifests" / "work-unit.yaml").read_text(encoding="utf-8")) |
| 28 | assert manifest["steps"]["alpha"]["verified"] is True |
| 29 | |
| 30 | |
| 31 | def test_cli_verify_fail_exit_10(tmp_path: Path) -> None: |
| 32 | seed_checkpoint_repo(tmp_path) |
| 33 | manifest_path = tmp_path / "manifests" / "work-unit.yaml" |
| 34 | data = yaml.safe_load(manifest_path.read_text(encoding="utf-8")) |
| 35 | data["template_id"] = "three_step" |
| 36 | data["current_step"] = "gamma" |
| 37 | data["steps"]["alpha"]["verified"] = True |
| 38 | data["steps"]["beta"]["verified"] = True |
| 39 | data["steps"]["gamma"] = {"verified": False, "verified_at": None, "artifact_sha256": None} |
| 40 | manifest_path.write_text(yaml.safe_dump(data), encoding="utf-8") |
| 41 | before = manifest_path.read_bytes() |
| 42 | code = run_cli( |
| 43 | ["verify-step", "--step", "gamma"], |
| 44 | cwd=tmp_path, |
| 45 | runner=git_status_runner(), |
| 46 | kit=kit_root(), |
| 47 | ) |
| 48 | assert code == 10 |
| 49 | assert manifest_path.read_bytes() == before |
| 50 | |
| 51 | |
| 52 | def test_cli_all_happy_path(tmp_path: Path) -> None: |
| 53 | seed_checkpoint_repo(tmp_path) |
| 54 | code = run_cli( |
| 55 | ["verify-step", "--all"], |
| 56 | cwd=tmp_path, |
| 57 | runner=git_status_runner(), |
| 58 | kit=kit_root(), |
| 59 | ) |
| 60 | assert code == 0 |
| 61 | manifest = yaml.safe_load((tmp_path / "manifests" / "work-unit.yaml").read_text(encoding="utf-8")) |
| 62 | assert manifest["steps"]["alpha"]["verified"] is True |
| 63 | assert manifest["steps"]["beta"]["verified"] is True |
| 64 | |
| 65 | |
| 66 | def test_cli_through_current_all_verified_noop(tmp_path: Path, capsys) -> None: |
| 67 | seed_checkpoint_repo(tmp_path) |
| 68 | (tmp_path / "manifests" / "work-unit.yaml").write_text( |
| 69 | (CHECKPOINTS / "manifests" / "all-verified.yaml").read_text(encoding="utf-8"), |
| 70 | encoding="utf-8", |
| 71 | ) |
| 72 | code = run_cli( |
| 73 | ["verify-step", "--through", "current", "--json"], |
| 74 | cwd=tmp_path, |
| 75 | runner=git_status_runner(), |
| 76 | kit=kit_root(), |
| 77 | json_mode=True, |
| 78 | ) |
| 79 | assert code == 0 |
| 80 | payload = json.loads(capsys.readouterr().out) |
| 81 | assert payload["steps"] == [] |
| 82 | |
| 83 | |
| 84 | def test_cli_dry_run_leaves_manifest_unchanged(tmp_path: Path) -> None: |
| 85 | seed_checkpoint_repo(tmp_path) |
| 86 | manifest_path = tmp_path / "manifests" / "work-unit.yaml" |
| 87 | before = manifest_path.read_bytes() |
| 88 | code = run_cli( |
| 89 | ["verify-step", "--step", "alpha", "--dry-run"], |
| 90 | cwd=tmp_path, |
| 91 | runner=git_status_runner(), |
| 92 | kit=kit_root(), |
| 93 | ) |
| 94 | assert code == 0 |
| 95 | assert manifest_path.read_bytes() == before |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
8 hours ago