Files
Aislo/resources/tester/test_725_1_sangeun_add_inputs.py
T
eomsangdonandClaude Sonnet 5.5 6a429560fb fix(725-6): 바탕 없는 단가산출 공통 옵션 칸(더한줄 로직 입력 모음) · 상세 못 셈 줄 금액 「—」 + 까닭 풍선
- 바탕 없는 SK = 더한줄 로직 입력을 모아(같은 이름 하나) 공통 옵션 칸으로 보임 · 값 자리 = 시험 입력 그대로 · 바탕 있으면 지금 그대로
- 입력 바꾸면 SK 셈 바로(바탕 없음 = 시험 계산 단추 없음) · 셈 때 SK 줄 입력 아닌 이름은 거름(공통 옵션 지역이 SK 줄에서 「모르는 입력」으로 멈춤)
- 공용 상세 줄 금액 칸 = 까닭 있는 줄만 「—」 + 풍선(M01 줄은 까닭 없음 = 전후 같음)
- 시험 test_725_1 에 바탕 없음 지역 서울 5,297.37 · 화면 짜임 단언 더함

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 00:49:31 +09:00

117 lines
5.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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
def test_no_base_common_option_seoul(world): # noqa: F811
"""725-6 — 바탕 없는 SK 도 공통 옵션(지역 서울) 따라감 = M01 셈."""
doc = _sk(world["personal"], 더한줄=[GF_LINE])
got = _run(world["personal"], doc, {"지역": "서울"})
assert got["빠진줄"] == [], got
assert got["기준"], {k: v for k, v in got.items() if k != "줄"}
assert got["기준"]["계"] == pytest.approx(_m01(GF, {"지역": "서울", "보정작업": "해당 없음"}))
assert round(float(got["기준"]["계"]), 2) == 5297.37
def test_screen_no_base_inputs_and_gap_dash():
"""725-6 화면 — 바탕 없음 = 더한줄 로직 입력 모음 칸 · 못 셈 줄 금액 「—」 + 까닭 풍선."""
ts = (ROOT / "M02_MasterTemplete" / "M02_MasterTemplete_Sangeun_Detail.ts").read_text("utf-8")
assert "입력: extra" in ts and "syncExtra" in ts and "if (!base) void recalc()" in ts
ho = (ROOT / "M01_MasterData" / "M01_MasterData_UI_LogicLab_Ho.ts").read_text("utf-8")
assert "e.line?.까닭 ? gapCell" in ho and "title: why" in ho