Merge remote-tracking branch 'origin/sub_laptop_7' into main_laptop_1

# Conflicts:
#	M02_MasterTemplete/M02_MasterTemplete_Sangeun_Detail.ts
#	resources/tester/test_717_4_sangeun_pick.py
This commit is contained in:
2026-11-02 00:15:31 +09:00
7 changed files with 215 additions and 21 deletions
+2 -1
View File
@@ -141,7 +141,8 @@ def test_precombo_holds_sangeun(world):
"담은로직": [{"참조": {**MINE, "키": sk}, "수량": {"손": 2}}],
},
)["이름"]
got = labor.calc({"담은로직": [{"참조": {**MINE, "키": sc}, "수량": {"손": 1}}]}, {})
pill = {f"{refs.ref_id({**MINE, '키': sc})}#0": 2} # 723-1 안 줄 수량 = 쓰는 쪽 알약
got = labor.calc({"담은로직": [{"참조": {**MINE, "키": sc}, "수량": {"손": 1}}]}, pill)
with pytest.raises(store.StoreError) as e:
store.delete("sangeun", sk)
one = _calc(world["personal"], sk)["1단위"]["계"]
+3 -2
View File
@@ -122,8 +122,9 @@ def test_SK_단가_덮개_속_일위대가_펼침(world, tmp_path):
if not _engine_ready(world):
pytest.skip("715-1b 엔진 입력 덧칸(단가 · 값묶음) 뒤 — 지금은 M02 SK 셈도 못 함")
key = _mine(world, full=True)
# 723-1 = 속 일위대가 안 줄 수량 저장 안 함 → M02 SK = 수량 없음 · B09 = 그 줄만 빈 줄(이 공사 입력)
assert "수량 없음" in _calc(world["personal"], key)["까닭"]
# 723-1 속 일위대가 안 줄 수량 없음 → M02 SK = 그 줄만 빠짐(725-2) · B09 = 그 줄만 빈 줄
gone = _calc(world["personal"], key)["빠진줄"]
assert len(gone) == 1 and "수량 없음" in gone[0]["까닭"]
root, folder = _lib(world, tmp_path, key)
daega, done, _ = _b09(root)
block = done[daega["libs"][folder]]
@@ -0,0 +1,98 @@
"""725-1 · 725-2 단가산출 [항목 추가] 못 셈 줄 — 더한줄 로직 입력 = 공통 옵션 › 로직 기본값 ·
그래도 빈 입력 · 수량 없는 일위대가 줄 = 그 줄만 금액 없음 + 까닭 · 나머지 셈 계속(임시 storage)."""
from __future__ import annotations
from pathlib import Path
import pytest
from M01_MasterData import M01_MasterData_Store as m01
from M02_MasterTemplete import M02_Labor_Doc as labor
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 resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층
ROOT = Path(__file__).resolve().parents[2]
GF = "GF000099" # 측구터파기 토사 · 입력 지역 · 보정작업
PCT = "GC001109" # 입력 없음 · 인력 둘 + 덧줄 %
GF_LINE = {"종류": "로직", "로직": GF, "입력값": {}, "수량": 1}
PCT_LINE = {"종류": "로직", "로직": PCT, "입력값": {}, "수량": 1}
def _sk(folder, **doc):
with store.at(folder):
made = refs.create("sangeun", {"이름": "sub7임시", "단위": "㎥", "더한줄": [], **doc})
return store.read("sangeun", made["이름"])["문서"]
def _run(folder, doc, given=None):
with store.at(folder):
return calc.calc_doc(doc, given)
def _line(got, cid):
return next(x for x in got["줄"] if x["cid"] == cid)
def _m01(code, values):
return float(labor.run_line(m01.loaded()[1], code, values, None, None)["기준"]["계"])
@pytest.mark.parametrize(
("given", "want"),
[
(None, {"지역": "전국평균", "보정작업": "해당 없음"}), # 로직 기본값
({"지역": "서울"}, {"지역": "서울", "보정작업": "해당 없음"}), # 공통 옵션 › 기본값
],
)
def test_added_logic_takes_common_then_default(world, given, want): # noqa: F811
"""입력 있는 로직 더한줄(입력값 {}) = 공통 옵션 넣은 M01 셈 · 계 = 바탕 + 그 줄."""
doc = _sk(world["personal"], 바탕={"로직": GF}, 더한줄=[GF_LINE])
plain = _sk(world["personal"], 바탕={"로직": GF})
got, bare = _run(world["personal"], doc, given), _run(world["personal"], plain, given)
one = _m01(GF, want)
assert got["빠진줄"] == [] and not got.get("까닭")
assert _line(got, "add:#0")["금액"] == pytest.approx(one, rel=1e-9)
assert got["기준"]["계"] - bare["기준"]["계"] == pytest.approx(one, rel=1e-9)
assert doc["더한줄"][0]["입력값"] == {} # 문서에 안 적음 — 공통 옵션을 바꾸면 따라감
def test_line_without_input_only_that_line_drops(world, monkeypatch): # noqa: F811
"""기본값도 없는 입력 = 그 줄만 금액 — · 까닭 · 계 = 나머지 · 쓰는 자리 = 기준 없음."""
monkeypatch.setattr(calc, "_defaults", lambda whole, code: {})
doc = _sk(world["personal"], 더한줄=[GF_LINE, PCT_LINE])
rest = _sk(world["personal"], 더한줄=[PCT_LINE])
got, want = _run(world["personal"], doc), _run(world["personal"], rest)
gap = _line(got, "add:#0")
assert gap["금액"] is None and gap["까닭"] == "입력 「지역」 없음"
assert got["빠진줄"] == [{"cid": "add:#0", "이름": gap["이름"], "까닭": "입력 「지역」 없음"}]
assert gap["이름"] # 이름 남음 — 화면 줄 빼기 자리
assert got["기준"]["계"] == pytest.approx(float(want["기준"]["계"]), rel=1e-9)
assert _line(got, "add:#1")["금액"] == pytest.approx(float(want["기준"]["계"]), rel=1e-9)
with store.at(world["personal"]):
up = refs.Expand(m01.loaded()[1])({**MINE, "키": doc["키"]})
assert up["기준"] is None and "입력 「지역」 없음" in up["까닭"]
def test_precombo_without_qty_only_that_line_drops(world): # noqa: F811
"""수량 없는 일위대가 줄(723-1) = 그 줄만 금액 — · 까닭 · 나머지 계 같음."""
with store.at(world["personal"]):
sc = refs.create(
"precombo", {"이름": "sub7임시SC", "단위": "㎥", "담은로직": [{"로직": PCT}]}
)
line = {"참조": {**MINE, "키": sc["이름"]}, "수량": 2}
doc = _sk(world["personal"], 더한줄=[line, PCT_LINE])
rest = _sk(world["personal"], 더한줄=[PCT_LINE])
got, want = _run(world["personal"], doc), _run(world["personal"], rest)
gap = _line(got, "add:#0")
assert gap["금액"] is None and gap["까닭"] == calc.NO_QTY_WHY and gap["이름"] == "sub7임시SC"
assert [x["cid"] for x in got["빠진줄"]] == ["add:#0"]
assert got["기준"]["계"] == pytest.approx(float(want["기준"]["계"]), rel=1e-9)
def test_screen_shows_dropped_lines():
"""화면 — 빠진 줄 띠(이름 · 까닭) · 금액 없는 줄 계산서 금액 —."""
ts = (ROOT / "M02_MasterTemplete" / "M02_MasterTemplete_Sangeun_Detail.ts").read_text("utf-8")
assert "ans?.빠진줄" in ts and 'L("M02_SangeunGap")' in ts