test_status.py python
63 lines 1.8 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 13 hours ago
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
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 13 hours ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 52 days ago