Files
Aislo/resources/tester/test_855_block.py
T
eomsangdonandClaude Opus 5.5 df96db9dcc test(855-E 2-E4 ㉮-1): helper_855_engine 새 쪽만 남김 — 옛 엔진 대조 은퇴
- helper_855_engine: world = (색인 · 수식 문서 · 연결) · doc_cases · new_run · answer · fingerprint 만 남김 — 옛 쪽(cases · old_run · level · adopted · _old_env · _old_captured · old_line_calls)과 master_formula · master_cut · master_equation · 빌더 import 지움 · 지문 같음(골든 전수 1,521 통과)
- test_855_engine_parity git rm — 옛 엔진 ↔ 새 계산기 대조(다름 0 은 걸음마다 확인됨) · 뒤는 test_855_golden 이 지킴
- test_855_trace: 옛 가로채기 자원 키 · 옛 하위 부름(line_calls) 대조 둘 지움 · 기록 켜도 셈 답 같음 · 고른 품목 · 기계경비 부름은 그대로 · 셈 문서 수 > 1000(빈 통과 막음) · 전수 = 수식 문서 전부
- test_855_block: 옛 check_logic 대조 둘(옛 = 새 · 틀린 식 두 판정) 지움 · 문서 막힘 화면 답 · 저장 검사 · 요소 닫힘 셋 그대로
- test_855_golden · test_855_e4a_base_only: world 차례 고침만

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:51:01 +09:00

83 lines
4.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""855-A 지킴 ④ — 막힘 판정 = 수식 문서 표지(`master_doc_block`) · 화면 답 · 저장 검사 · 요소 닫힘.
옛 `master_formula.check_logic` 대조(옛 = 새 전수 · 틀린 식 두 판정)는 855-E 2-E4 에서 은퇴."""
from __future__ import annotations
import importlib
import helper_855_engine as h
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))