# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀 """790-2 단가산출(SK) 글 줄 · 까닭 칸 꼴 · 옛 SK 셈 답(요구서_652). - 글줄 · 까닭 = 꼴 검사 · 빈 칸 안 둠 · 상수 · 표값 덮개 = 셈 은퇴 뒤 받지 않음(855 2-E2 · 시험 792_1) - 옛 SK(새 칸 없음) = 꼴 · 금액 그대로 · M01판 = 서버 몫(버림) """ from __future__ import annotations import pytest from M01_MasterData import M01_MasterData_Store as m01 from M02_MasterTemplete import M02_Labor_Ref as refs from M02_MasterTemplete import M02_MasterTemplete_Store as store from M02_MasterTemplete import M02_Sangeun_Calc as calc from M02_MasterTemplete import M02_Sangeun_Const as const from M02_MasterTemplete import M02_Sangeun_Doc as sd from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층 FORM = "GC000211" # 합판거푸집 F211 = { "자재지역": "포항", "유형": "보통", "사용횟수": "6회", "높이감률": 0, "지붕슬래브": "아님", "폼타이": "아님", "폼타이규격": "12.7㎜", "측압": "3t/㎡", "구멍땜": 0, } def _whole(): return m01.loaded()[1] def _doc(code, given, **more): return { "키": "SK-000001", "이름": "견본", "단위": "식", "바탕": {"로직": code}, "입력값": given, **more, } # ── 문서 꼴 ────────────────────────────────────────────────────────── def test_새_칸_꼴_검사(): whole = _whole() doc = _doc( FORM, F211, 글줄=[{"자리": "", "글": " 건설표준품셈 6-3-1 "}, {"자리": "mid:시공량", "글": ""}], 까닭={"mid:시공량": "현장 경사 반영", "add:#0": " ", "add:#1/labor:LB000002#0": "x"}, ) got = sd.clean(doc, None, whole) assert got["글줄"] == [{"자리": "", "글": "건설표준품셈 6-3-1"}] assert got["까닭"] == {"mid:시공량": "현장 경사 반영", "add:#1/labor:LB000002#0": "x"} for bad in ( {"까닭": {"x": "y"}}, {"글줄": [{"자리": "", "글": "가" * 501}]}, ): with pytest.raises(sd.DocError): sd.clean(_doc(FORM, F211, **bad), None, whole) def test_옛_SK_꼴_금액_그대로(): whole = _whole() old = _doc(FORM, F211, 덮개={"labor:LB000007#0": {"qty": 0.2}}, 뺀줄=["labor:LB000002#0"]) got = sd.clean(old, None, whole) assert not set(got) & {*const.NEW, "M01판"} assert sd.clean({**old, "M01판": {"mid:시공량": "x"}}, None, whole) == got # M01판 = 서버 몫 # ── 저장 · 셈 답(임시 storage) ───────────────────────────────────────── def _sk(folder, **doc): with store.at(folder): return refs.create("sangeun", {"이름": "내 단가산출", "단위": "식", "더한줄": [], **doc})[ "이름" ] def _read(folder, key): with store.at(folder): return store.read("sangeun", key)["문서"] def _calc(folder, doc, given=None): with store.at(folder): return calc.calc_doc(doc, given) def test_옛_저장본_셈답(world): """새 칸 없는 옛 저장본(M01판 없음) = 금액 그대로(옛 `원래` · `시트` 덧칸은 855 2-C1 에서 걷음).""" got = _calc(world["personal"], {**_doc(FORM, F211), "바탕판": "0" * 16}) assert got["기준"]["계"] == 51419