test_check_ok_scaffold.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 — Check-if-OK scaffold + footprint membership."""
2
3 from __future__ import annotations
4
5 from datetime import date
6 from pathlib import Path
7
8 import pytest
9
10 from cli.footprint import resolve_footprint
11 from tools.check_ok.scaffold import (
12 render_side_check_markdown,
13 resolve_artifact_path,
14 scaffold_side_check,
15 slugify_topic,
16 )
17
18
19 def test_slugify_topic_normalizes() -> None:
20 assert slugify_topic(" My Side Research!! ") == "my-side-research"
21 assert slugify_topic("") == "side-check"
22
23
24 def test_render_includes_frozen_true_and_seven_tiers() -> None:
25 body = render_side_check_markdown(
26 topic="demo",
27 phase_id="check-ok-demo",
28 scope="Scope text with seven-tier coverage.",
29 output_path="docs/reviews/2026-07-17-demo.md",
30 date_stamp="2026-07-17",
31 )
32 assert "frozen: true" in body
33 assert "phase: check-ok-demo" in body
34 assert "seven-tier" in body.lower() or "Seven tiers" in body or "| unit |" in body
35 assert "file+line" in body
36
37
38 def test_resolve_artifact_path_default_under_reviews(tmp_path: Path) -> None:
39 target = resolve_artifact_path(
40 tmp_path,
41 topic="spike",
42 today=date(2026, 7, 17),
43 )
44 assert target == tmp_path / "docs" / "reviews" / "2026-07-17-spike.md"
45
46
47 def test_scaffold_creates_then_reuses(tmp_path: Path) -> None:
48 first = scaffold_side_check(
49 tmp_path,
50 topic="spike",
51 scope="Unit scope.",
52 today=date(2026, 7, 17),
53 )
54 assert first.created is True
55 assert first.path.is_file()
56 assert "frozen: true" in first.path.read_text(encoding="utf-8")
57
58 second = scaffold_side_check(
59 tmp_path,
60 topic="spike",
61 today=date(2026, 7, 17),
62 )
63 assert second.created is False
64 assert second.rel_path == first.rel_path
65
66
67 def test_scaffold_path_escape_refused(tmp_path: Path) -> None:
68 with pytest.raises(ValueError, match="path-escape"):
69 scaffold_side_check(tmp_path, path="../outside.md")
70
71
72 def test_footprint_includes_check_ok_skill_and_rule(git_only_config) -> None:
73 dests = {f.destination for f in resolve_footprint(git_only_config)}
74 assert ".cursor/skills/check-ok/SKILL.md" in dests
75 assert ".cursor/skills/check-ok/SIDE-CHECK-TEMPLATE.md" in dests
76 assert ".cursor/rules/check-ok-thinking.mdc" in dests
77 # Claude Code twin (same source bytes)
78 assert ".claude/skills/check-ok/SKILL.md" in dests
79 assert ".claude/skills/freeze-review/SKILL.md" in dests
80
81
82 def test_skill_documents_same_engine_as_review(git_only_config) -> None:
83 files = {f.destination: f.text for f in resolve_footprint(git_only_config)}
84 skill = files[".cursor/skills/check-ok/SKILL.md"]
85 assert "ok review --freeze" in skill
86 assert "ok check-ok" in skill
87 assert "build-verification-review" in skill
88 assert "docs.lanes" in skill
89 assert files[".claude/skills/check-ok/SKILL.md"] == skill