test_config.py python
111 lines 3.9 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 2 days ago
1 """Unit tests for config schema validation fail-closed branches."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 import pytest
8
9 from adapters.config import SUPPORTED_CONFIG_VERSION, load_config
10 from adapters.errors import ConfigError
11 from tests.support import load_fixture_config, write_config
12
13
14 def test_load_valid_git_only_config(git_only_config) -> None:
15 assert git_only_config.vcs.regime == "git-only"
16 assert git_only_config.overseer_config_version == SUPPORTED_CONFIG_VERSION
17 assert git_only_config.docs.handover_title == "Overseer Handover"
18 assert git_only_config.docs.roadmap_title == "Roadmap"
19
20
21 def test_missing_config_raises(tmp_path: Path) -> None:
22 with pytest.raises(ConfigError, match="missing"):
23 load_config(tmp_path / ".overseer" / "config.yaml")
24
25
26 def test_unparseable_yaml_raises(tmp_path: Path) -> None:
27 path = tmp_path / ".overseer" / "config.yaml"
28 path.parent.mkdir(parents=True)
29 path.write_text(":\n bad:\n- yaml", encoding="utf-8")
30 with pytest.raises(ConfigError, match="unparseable"):
31 load_config(path)
32
33
34 def test_unknown_config_version_raises(repo_root: Path) -> None:
35 path = write_config(repo_root, "config-git-only.yaml")
36 text = path.read_text(encoding="utf-8").replace(
37 "overseer_config_version: 1",
38 "overseer_config_version: 99",
39 )
40 path.write_text(text, encoding="utf-8")
41 with pytest.raises(ConfigError, match="unsupported overseer_config_version"):
42 load_config(path)
43
44
45 def test_unknown_regime_raises(repo_root: Path) -> None:
46 path = write_config(repo_root, "config-git-only.yaml")
47 text = path.read_text(encoding="utf-8").replace(
48 "regime: git-only",
49 "regime: svn-only",
50 )
51 path.write_text(text, encoding="utf-8")
52 with pytest.raises(ConfigError, match="unsupported vcs.regime"):
53 load_config(path)
54
55
56 def test_git_only_with_muse_fields_raises(repo_root: Path) -> None:
57 path = write_config(repo_root, "config-git-only.yaml")
58 text = path.read_text(encoding="utf-8").replace(
59 "main_branch: null",
60 'main_branch: "main"',
61 1,
62 )
63 path.write_text(text, encoding="utf-8")
64 with pytest.raises(ConfigError, match="muse fields to be null"):
65 load_config(path)
66
67
68 def test_muse_git_mirror_missing_mirror_branch_raises(repo_root: Path) -> None:
69 path = write_config(repo_root, "config-muse-git-mirror.yaml")
70 text = path.read_text(encoding="utf-8").replace(
71 "mirror_branch: muse-mirror",
72 "mirror_branch: null",
73 )
74 path.write_text(text, encoding="utf-8")
75 with pytest.raises(ConfigError, match="mirror_branch"):
76 load_config(path)
77
78
79 def test_load_two_lane_config(repo_root: Path) -> None:
80 cfg = load_fixture_config(repo_root, "config-two-lane.yaml")
81 assert cfg.docs.default_lane == "queue"
82 assert cfg.docs.lanes is not None
83 assert set(cfg.docs.lanes) == {"queue", "active"}
84 assert cfg.docs.lanes["active"].handover == "videos/_active/HANDOVER.md"
85
86
87 def test_lanes_default_lane_mismatch_raises(repo_root: Path) -> None:
88 path = write_config(repo_root, "config-two-lane.yaml")
89 text = path.read_text(encoding="utf-8").replace(
90 "handover: QUEUE_HANDOVER.md",
91 "handover: WRONG.md",
92 1,
93 )
94 path.write_text(text, encoding="utf-8")
95 with pytest.raises(ConfigError, match="must match docs.lanes"):
96 load_config(path)
97
98
99 def test_resolve_lane_docs_single_lane(git_only_config) -> None:
100 from adapters.config import resolve_lane_docs
101
102 docs = resolve_lane_docs(git_only_config, None)
103 assert docs.handover == git_only_config.docs.handover
104
105
106 def test_resolve_lane_docs_unknown_lane_raises(repo_root: Path) -> None:
107 from adapters.config import resolve_lane_docs
108
109 cfg = load_fixture_config(repo_root, "config-two-lane.yaml")
110 with pytest.raises(ConfigError, match="unknown lane"):
111 resolve_lane_docs(cfg, "missing")
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 2 days ago