"""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["갈래"] != "표" }