- 새 master_doc_block — 문서 막힘 = 문서 검사 표지 + 단가산출 부름 닫힘 · 넘긴 입력 이름 + 요소 닫힘(요소 · 표 키 · 선택 구멍 펼친 키 · 재료 고르기 후보) · 저장 검사는 문서 사이 순환까지 · 문서 없는 새 줄 = 막힘 아님(지금 그대로) - M01 /logic blocked · reasons · 목록 막힘(Store_Cache._check · 부름 · 본 요소 지도도 문서에서) · 일위대가 조합 막힘(M01 Store_Combo · M02 Combo_Store = problems_of) = 새 길 · 서버 답 꼴 그대로 - 저장 검사 로직 몫 = 옛 check_logics(좁힌 줄) 먼저 · 깨끗하면 문서 막힘 — 로직 줄은 아직 옛 엔진 길이 씀 · L3 에서 걷음 · 조합 몫 = 문서로 - 자체 기계 등록 · 뺌이 수식 문서 목록에 저장 뒤 들어가는 것을 저장 검사가 미리 봄(Store_Cache.picks · Machine.relist) - 옛 검사 본체(mf.check_logic · mcb.check_all · check_row)는 그대로 · 쓰지 않게 된 _Watch 만 걷음 - 시험: test_855_block 에 화면 답 = 새 길 · 저장 부름 닫힘 · 순환 · 요소 닫힘 · 넘긴 입력 단언 · test_m01_make 준비 = 수식 문서도 사본(새 로직 문서가 생김) · test_m01_cache 부르는 줄 다시 셈 = 문서 기준으로 고침(목록 = 문서 기준이라 로직 JSON 만 고치면 목록은 안 막힘 — 뜻한 바뀜 · 저장 검사는 옛 check_logics 가 로직 줄을 지킴) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
5.2 KiB
Python
107 lines
5.2 KiB
Python
"""855-A 지킴 ④ — 막힘 판정 옛(`master_formula.check_logic` · M01 로직 목록 · `/logic`) = 새(수식 문서
|
||
표지 `master_doc.check`) 전수 · 막힘 기준 = 표지만(기본 입력으로 셈이 안 되는 것은 막힘 아님 · 판정 855-0).
|
||
|
||
걸음 2-B3(막힘 검사를 문서 기준으로) 앞뒤로 같아야 함 · 옛 검사를 지우는 걸음에서 옛 쪽만 뗌."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import importlib
|
||
|
||
import helper_855_engine as h
|
||
|
||
md = importlib.import_module("master_doc")
|
||
|
||
|
||
def test_막힘_옛_새_같음():
|
||
rows, whole, docs, _ = h.world()
|
||
old = {str(r["키"]) for r in rows if h.mf.check_logic(whole, r)[0]}
|
||
new = {str(r["키"]) for r in rows if str(r["키"]) not in docs or md.check(docs[str(r["키"])])}
|
||
assert old == new, {"옛만 막힘": sorted(old - new)[:20], "새만 막힘": sorted(new - old)[:20]}
|
||
|
||
|
||
def test_틀린_식은_옛_새_모두_막힘():
|
||
"""자가 살아 있는지 — 같은 로직의 식을 틀리게 하면 두 판정 모두 막힘(사본만 · 자료 안 고침)."""
|
||
import copy
|
||
|
||
rows, whole, docs, _ = h.world()
|
||
row = next(r for r in rows if r.get("호표") and str(r["키"]) in docs)
|
||
bad_row = copy.deepcopy(row)
|
||
bad_row["호표"][0]["수량"] = "없는변수 * 2"
|
||
bad_doc = copy.deepcopy(docs[str(row["키"])])
|
||
bad_doc["금액"][0]["수량"] = "없는기호 × 2"
|
||
assert h.mf.check_logic(whole, bad_row)[0]
|
||
assert md.check(bad_doc)
|
||
|
||
|
||
def test_화면_답이_문서_막힘_길을_씀(monkeypatch):
|
||
"""2-B3 뒤 — M01 `/logic` 막힘 · 목록 막힘 · 일위대가 조합 막힘이 수식 문서 기준(`master_doc_block`).
|
||
문서 하나를 틀리게(사본) 하면 로직 줄은 그대로인데 화면 답이 막힘으로 바뀜 · 문서가 빠지면 조합도 막힘."""
|
||
import copy
|
||
|
||
from M01_MasterData import M01_MasterData_Doc as doc_store
|
||
from M01_MasterData import M01_MasterData_Store as store
|
||
from M01_MasterData import M01_MasterData_Store_Combo as combo_store
|
||
|
||
real = doc_store.docs()
|
||
key = next(k for k, d in real.items() if d.get("금액"))
|
||
assert not store.logic(key)["blocked"] and not store.blocks()[key]
|
||
bad = copy.deepcopy(real[key])
|
||
bad["금액"][0]["수량"] = "없는기호 × 2"
|
||
monkeypatch.setattr(doc_store, "docs", lambda: {**real, key: bad})
|
||
got = store.logic(key)
|
||
assert got["blocked"] and any("없는기호" in x for x in got["reasons"])
|
||
assert store.blocks()[key] == got["reasons"]
|
||
|
||
row = {"키": "UA999999", "이름": "시험", "담은로직": [{"로직": key}]}
|
||
assert combo_store.problems_of(row) == []
|
||
monkeypatch.setattr(doc_store, "docs", lambda: {k: d for k, d in real.items() if k != key})
|
||
assert combo_store.problems_of(row) == [f"UA999999 시험 줄1 · 없는 요소 「{key}」"]
|
||
assert store.logic(key)["reasons"] == [] # 문서 없는 줄 = 막힘 아님(지금 그대로)
|
||
|
||
|
||
def test_저장_검사_부름_닫힘_순환():
|
||
"""저장 검사 로직 몫(`master_doc_block.check_docs`) — 부르는 단가산출이 빠지면 막힘 · 문서 사이 순환."""
|
||
mb = importlib.import_module("master_doc_block")
|
||
_, _, docs, _ = h.world()
|
||
caller = next(k for k, d in docs.items() if mb.calls(d))
|
||
called = sorted(mb.calls(docs[caller]))[0]
|
||
assert not mb.check_docs(docs, {caller})
|
||
gone = {k: d for k, d in docs.items() if k != called}
|
||
assert any(f"「{called}」 없음" in x for x in mb.check_docs(gone, {caller}))
|
||
a = {"꼴": "수식문서", "키": "GX900001", "변수": [{"열쇠": "b", "기호": "b", "연결": {"갈래": "단가산출", "키": "GX900002"}}]} # fmt: skip
|
||
b = {**a, "키": "GX900002", "변수": [{"열쇠": "a", "기호": "a", "연결": {"갈래": "단가산출", "키": "GX900001"}}]} # fmt: skip
|
||
assert any("돌고 도는 참조" in x for x in mb.check_docs({"GX900001": a, "GX900002": b}, set()))
|
||
|
||
|
||
def test_요소_닫힘_쓰이는_요소가_없으면_막힘():
|
||
"""요소 닫힘 — 문서가 부르는 요소 · 표가 마스터에 없으면 막힘(쓰이는 요소를 지우면 저장이 막는 지금 동작 지킴) ·
|
||
단가산출에 넘기는 입력 이름이 부르는 문서에 없으면 막힘."""
|
||
import copy
|
||
|
||
mb = importlib.import_module("master_doc_block")
|
||
_, whole, docs, _ = h.world()
|
||
key, doc = next(
|
||
(k, d)
|
||
for k, d in docs.items()
|
||
if any(
|
||
(v.get("연결") or {}).get("갈래") == "요소"
|
||
and str((v.get("연결") or {}).get("키") or "").startswith("LB0")
|
||
for v in d.get("변수") or []
|
||
)
|
||
)
|
||
assert not mb.reasons(key, doc, docs, whole)
|
||
gone = copy.deepcopy(doc)
|
||
link = next(
|
||
v["연결"]
|
||
for v in gone["변수"]
|
||
if str((v.get("연결") or {}).get("키") or "").startswith("LB0")
|
||
)
|
||
link["키"] = "LB999999"
|
||
assert any("LB999999" in x for x in mb.reasons(key, gone, docs, whole))
|
||
|
||
caller = next(k for k, d in docs.items() if mb.calls(d))
|
||
bad = copy.deepcopy(docs[caller])
|
||
call = next(v["연결"] for v in bad["변수"] if (v.get("연결") or {}).get("갈래") == "단가산출")
|
||
call["입력"] = {**(call.get("입력") or {}), "없는입력": "1"}
|
||
assert any("없는입력" in x for x in mb.reasons(caller, bad, docs, whole))
|