Files
Aislo/resources/tester/test_pum_md_locked.py
T
eomsangdonandClaude Opus 5 56343d8088 knowledge(품셈md): 도구 check · pages · status + 잠금 시험
- check: ① 수(갯수까지) ② 글자(공백 뗌) 양방향 대조 · 어긋난 자리를 쪽·줄로 출력 · 머리 기계검사 칸에 적음
- md 쪽은 머리 · 주석 · 그림 · 표 문법 · 제목·인용 표시 · 첨자 표시를 빼고, 막음표(\) 뒤 글자는 원문으로 셈
- 확정 파일은 통과할 때 확정지문(LF 로 센 sha256)을 한 번만 적음 — 있는 지문은 안 덮음
- pages: 쪽 그림 150dpi → tmp/pum_pages(git 밖) · status: 장별 상태 표
- test_pum_md_locked.py: 확정 파일 지문·①② 0 · 머리 칸 다 있음

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
2026-09-19 01:27:15 +09:00

43 lines
1.5 KiB
Python

"""품셈 md 잠금 — 상태 `확정` 파일은 확정지문이 맞고 기계검사 ①② 가 0 (규칙 6장).
`확정` 뒤 파일이 바뀌면 빨강. 고치려면 상태를 `작성중` 으로 되돌리고 ①②③ 다시.
"""
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "resources/knowledge/original/_pipeline"))
import pum_md_tool as tool # noqa: E402
LOCKED = [
path
for book in tool.BOOKS.values()
for path in sorted(book["out"].rglob("*.md"))
if tool.read_head(path).get("상태") == "확정"
]
@pytest.mark.parametrize("path", LOCKED, ids=lambda p: p.name)
def test_locked_file_unchanged_and_clean(path):
head = tool.read_head(path)
assert head["확정지문"], "확정인데 지문이 없음 — check 를 돌려 적을 것"
assert tool.fingerprint(path.read_text(encoding="utf-8")) == head["확정지문"], (
"확정 뒤 파일이 바뀜 — 상태를 작성중으로 되돌리고 ①②③ 다시"
)
pytest.importorskip("pymupdf")
_, line = tool.check_file(path)
assert line.startswith("통과"), line
def test_heads_are_well_formed():
"""모든 새 md 머리 — 칸이 다 있고 상태가 넷 중 하나."""
for book in tool.BOOKS.values():
for path in book["out"].rglob("*.md"):
head = tool.read_head(path)
assert set(tool.HEAD_KEYS) <= set(head), path
assert head["상태"] in tool.STATES, f"{path}: {head['상태']}"