Files
Aislo/resources/tester/test_855_trace.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

81 lines
3.2 KiB
Python

"""855-F B9-1 지킴 — 문서 셈 기록(`master_doc_trace`) · 로직 전수 기본 입력.
- 기록을 켜도 셈 답 같음(줄 `부름` · 답 `부름` `자원` 칸만 더해짐).
- 고른 품목 = `master_pick.priced` 의 품목 키 · 줄 `부름` = 그 줄 자원.
- 옛 엔진 대조(자원 키 가로채기 · 하위 부름 `line_calls`)는 855-E 2-E4 에서 은퇴.
"""
from __future__ import annotations
import importlib
from functools import lru_cache
import helper_855_engine as h
mt = importlib.import_module("master_doc_trace")
mp = importlib.import_module("master_pick")
mm = importlib.import_module("master_material")
def mc_calc(doc: dict, links) -> dict:
return importlib.import_module("master_doc_calc").calc(doc, links)
def _strip(got: dict) -> dict:
out = {k: v for k, v in got.items() if k not in ("부름", "자원")}
if "줄" in out:
out["줄"] = [{k: v for k, v in ln.items() if k != "부름"} for ln in out["줄"]]
return out
@lru_cache(maxsize=1)
def survey() -> dict:
whole, docs, links = h.world()
trace = mt.Trace(whole, docs)
out = {"답 다름": [], "품목": [], "줄": [], "셈": 0}
for key, doc in docs.items():
got = mt.calc(doc, trace)
out["셈"] += 1
if _strip(got) != mc_calc(doc, links):
out["답 다름"].append(key)
for c in got["부름"]:
p = c["부름"]
if c["깊이"] == 1 and "품목" in c and p.get("재료") is not None:
env = {mm.REGION: p["지역"]} if p.get("지역") is not None else {}
if p.get("계약종별") is not None:
env[mm.TARIFF] = p["계약종별"]
want = mp.priced(whole, {"단위": p.get("단위")}, p["재료"], env, None)[3]
if want.get("품목") and want["품목"]["키"] != c["품목"]:
out["품목"].append((key, c["이름"], want["품목"]["키"], c["품목"]))
for ln in got.get("줄") or []:
for i in ln["부름"]:
if not (0 <= i < len(got["부름"])) or got["부름"][i]["깊이"] != 1:
out["줄"].append((key, ln["이름"], i))
return out
def test_기록_켜도_셈_답_같음():
assert survey()["셈"] > 1000 # 문서를 못 읽어 빈 통과하지 않게
assert survey()["답 다름"] == []
def test_고른_품목_줄_부름():
s = survey()
assert s["품목"] == []
assert s["줄"] == []
def test_기계경비_부름_기계_키_줄마다_부름():
whole, docs, _ = h.world()
got = mt.calc(
docs["GC000337"], mt.Trace(whole, docs)
) # 낙석방지망 — 인력 둘 · 크레인 · 재료 셋
lines = {ln["이름"]: [got["부름"][i] for i in ln["부름"]] for ln in got["줄"]}
crane = [c for c in lines["크레인"] if c["갈래"] == "단가산출"]
assert [c["부름"]["키"] for c in crane] == ["GC000268"] and crane[0]["기계"][:2] == "EQ"
assert {x["키"][:2] for c in lines["특별인부"] for x in c["자원"]} == {"LB", "QC"}
assert [c["품목"] for c in lines["에폭시"] if "품목" in c] == [got["자원"][-1]]
assert set(got["자원"]) >= {
x["키"] for c in got["부름"] for x in c["자원"] if x["갈래"] != "표"
}