test_status.py file-level

at sha256:a · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """Unit tests for ``overseer status``."""
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 git_status_runner, run_cli
14
15
16 def test_uninitialized_repo(tmp_path: Path) -> None:
17 code = run_cli(["status", "--json"], cwd=tmp_path)
18 assert code == 0
19
20
21 def test_status_schema_includes_last_governance_sync_null(tmp_path: Path) -> None:
22 run_cli(
23 ["init", "--regime", "git-only", "--non-interactive"],
24 cwd=tmp_path,
25 )
26 out = StringIO()
27 with patch("sys.stdout", out):
28 code = main(
29 ["status", "--json"],
30 ctx=CliContext.create(
31 cwd=tmp_path,
32 runner=git_status_runner(),
33 output=OutputContext(json_mode=True),
34 ),
35 )
36 assert code == 0
37 payload = json.loads(out.getvalue())
38 assert payload["last_governance_sync"] is None
39
40
41 def test_status_fail_closed_on_adapter_read_error(tmp_path: Path) -> None:
42 run_cli(
43 ["init", "--regime", "git-only", "--non-interactive"],
44 cwd=tmp_path,
45 )
46 from tests.support import fail, make_runner
47
48 code = run_cli(
49 ["status"],
50 cwd=tmp_path,
51 runner=make_runner({"git rev-parse --abbrev-ref HEAD": fail("broken", 1)}),
52 )
53 assert code == 2
54
55
56 def test_exit_code_precedence(tmp_path: Path) -> None:
57 run_cli(
58 ["init", "--regime", "git-only", "--non-interactive"],
59 cwd=tmp_path,
60 )
61 (tmp_path / ".overseer" / "config.yaml").write_text("bad: yaml\n", encoding="utf-8")
62 code = run_cli(["status", "--exit-code", "--check-footprint"], cwd=tmp_path)
63 assert code == 2