# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀 """812-4 지킴 — 율 값(%) 다름 = 참고(값은 M01 값으로 업데이트됨) · 율 대상 · 비목 다름 = 다른 항(로직). (a) 원파일 main 블록 105(터파기 · 리퍼 2.42 % ↔ 우리 유압식 리퍼 2 %) · 275(절토면고르기 리퍼) = 확정 + 참고 「율 값」 (다른 항 0) · 글에 「바꾸면 우리 값」 (b) 확정 + 참고 블록 [바꾸기] → 금액 = M01 사본 셈(율도 M01 값) · [되돌리기] → 원래 금액 · M01 문서 파일 그대로 (c) 대상이 다른 율(교량받침 1.14 % ↔ 공구손료 3 % 노임 노무비) = 여전히 다른 항 「율 대상」 원파일 없으면 skip(다른 PC) — 합성 줄 시험은 test_812_2. """ from __future__ import annotations import sys from decimal import Decimal as D from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] for p in (ROOT, HERE): if str(p) not in sys.path: sys.path.insert(0, str(p)) import test_810_2_native_doc as t2 # noqa: E402 import test_810_4_match as t4 # noqa: E402 from M02_MasterTemplete import M02_Doc_Match as dm # noqa: E402 from M02_MasterTemplete import M02_Doc_MatchSk as msk # noqa: E402 from M02_MasterTemplete import M02_MasterTemplete_Store as store # noqa: E402 from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh # noqa: E402 from resources.tester.test_m02_labor_ref import world # noqa: E402, F401 — 같은 임시 층 def _judge(no: int, tag: str = "main") -> dict: whole, _, index, links = t4.ctx() try: out = t2.fn.emit(t2.native("EST", tag), no) doc = t4.dim.derive(t2.sk_of(out), None, t2.whole()) except FileNotFoundError: pytest.skip("원파일 없음") return dm.match(doc, t4.dim.Links(whole, "우리"), index, links) @pytest.mark.parametrize(("no", "key"), [(105, "GC000089"), (275, "GC000111")]) def test_rate_value_only_is_sure_with_note(no: int, key: str) -> None: got = _judge(no) assert got["판정"] == dm.SURE and got["키"] == key and not got["다른"] rate = [d for d in got["참고"] if d["항"] == "율 값"] assert len(rate) == 1 and "바꾸면 우리 값" in rate[0]["글"] and "2 %" in rate[0]["글"] def test_rate_target_differs_stays_logic() -> None: got = _judge(1533) # 교량받침설치 — 율 대상 기계 · 노임 ↔ 노임 assert "율 대상" in {d["항"] for d in got["다른"]} and got["판정"] != dm.SURE def test_swap_rate_note_block_uses_m01_rate(world) -> None: folder = world["personal"] est = t2._file(t2.EST["main"]) before = {p.name: p.read_bytes() for p in dm.ml.FOLDER.glob("수식_*.json")} with store.at(folder): hp = fh.upload_native(folder, est.name, est.read_bytes(), t2.WHO)["키"] name = fh.make(folder, hp, 105)["이름"] old = store.read("sangeun", name) money0 = t4._money(name) found = msk.find(name, old["판"]) meta = found[dm.KEY] assert meta["판정"] == dm.SURE and any(d["항"] == "율 값" for d in meta["참고"]) assert t4._money(name) == money0 # 찾기 = 기록만 msk.swap(name, found["판"]) doc = store.read("sangeun", name)["문서"] want = dm._calc(dm.ml.load_all()[meta["키"]], dm.ml.Links(t2.whole()), dict(meta["옵션"])) assert t4._money(name) == [want[k] for k in t4.COSTS] # 율도 M01 값 assert doc["바탕"] == {"로직": meta["키"]} and sum(t4._money(name)) != sum(money0) msk.back(name, store.read("sangeun", name)["판"]) assert t4._money(name) == money0 # 되돌리기 = 원래 금액 assert D(sum(money0)) > 0 assert before == {p.name: p.read_bytes() for p in dm.ml.FOLDER.glob("수식_*.json")}