- POST /layers/{층}/sangeun/calc(calc_sangeun · _calc · SangeunCalcBody) 지움 — 화면 부름 0(856-2) · B08 · B09 · 서버 모듈 0
- POST /layers/{층}/{kind}-flat(library_flat · FlatBody) · Library_Flat.flat_lines 지움 — 화면 부름 0(찾아 넣기 = 참조 줄)
- calc_doc 의 seen 인자(몸에서 안 씀) · Sangeun_Calc.head_of · 답 머리 칸(화면만 먹던 띠) 걷음
- 시험: 778_2 = 길 대신 calc_doc 바로(같은 셈 묶음) · 740_1 = 넣기 길 단언 걷고 초기화 길만 · 792_1 = 펼침 막음을 const.no_flat 로 · 728_2 = head_of 단언 걷음(죽은 화면 띠) · 795_1 · 821_1 · 822_2 · 826_3 · 836_2 = seen 인자 뺌
- /openapi.json 길 480 → 478(뜻한 둘만 빠짐)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
3.6 KiB
Python
90 lines
3.6 KiB
Python
"""728-2 지킴 — SK 단위 환산: 바탕 기준단위 → SK 단위 배 · 화면 줄 · 계 = SK 1 단위 몫 ·
|
||
계수 없으면 셈 막음 · 「식」 = 옛 셈 · 돈 아닌 기초 고르기 창에서 뺌 ·
|
||
고침 꼴 화면배 되돌림."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import sys
|
||
from decimal import Decimal
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
ROOT = Path(__file__).resolve().parents[2]
|
||
HERE = Path(__file__).resolve().parent
|
||
sys.path.insert(0, str(ROOT))
|
||
sys.path.insert(0, str(ROOT / "resources/master_data/scripts"))
|
||
|
||
|
||
from M01_MasterData import M01_MasterData_Store as m01 # noqa: E402
|
||
from M02_MasterTemplete import M02_Sangeun_Calc as sc # noqa: E402
|
||
from M02_MasterTemplete import M02_Sangeun_Doc as sd # noqa: E402
|
||
|
||
|
||
@pytest.fixture(scope="module")
|
||
def whole():
|
||
return m01.loaded()[1]
|
||
|
||
|
||
def _doc(base, unit, **more):
|
||
return {"키": "SK-999999", "이름": "sub3임시", "단위": unit, "바탕": {"로직": base}, **more}
|
||
|
||
|
||
def _shown(whole, doc):
|
||
clean = sd.clean(doc, None, whole)
|
||
return sc.per_unit(sc.run(clean, whole), clean)
|
||
|
||
|
||
def test_단목베기_100본_제안_본으로_바꾸면_1본_계(whole):
|
||
full = _shown(whole, _doc("GF000287", "100본"))
|
||
assert full["배"] == 1 and full["기준"]["계"] == Decimal(
|
||
"255186"
|
||
) # 수식 문서 기본 옵션(흉고직경 14 · 단목 · 855 2-C1)
|
||
one = _shown(whole, _doc("GF000287", "본"))
|
||
assert one["배"] == 100 and round(one["기준"]["계"], 2) == Decimal("2551.86")
|
||
pairs = [(x["수량"], y["수량"]) for x, y in zip(full["줄"], one["줄"], strict=True)]
|
||
assert all(b == a / 100 for a, b in pairs) and one["화면배"] == 100 # 세부 품 ÷100
|
||
|
||
|
||
def test_사석_수상고르기_10제곱미터_에서_1제곱미터(whole):
|
||
one = _shown(whole, _doc("GC000421", "㎡"))
|
||
# 10㎡ 488,517(1 원 버림) ÷10 — 굴착기 조종원 시간당 283,296 × 5/24 = 59,020(840-5) × 1.72
|
||
assert one["기준"]["계"] == Decimal("48851.7")
|
||
|
||
|
||
def test_성격_다르면_계수_칸_없으면_셈_막음(whole):
|
||
with pytest.raises(sd.DocError, match="환산 계수"):
|
||
_shown(whole, _doc("GF000099", "m"))
|
||
base = _shown(whole, _doc("GF000099", "㎥"))["기준"]["계"]
|
||
two = _shown(whole, _doc("GF000099", "m", 환산={"계수": 2}))
|
||
assert two["배"] == 2 and two["기준"]["계"] == base / 2
|
||
with pytest.raises(sd.DocError, match="단위중량"):
|
||
_shown(whole, _doc("GF000099", "톤"))
|
||
rock = _shown(
|
||
whole, _doc("GF000099", "톤", 환산={"단위중량": {"종별": "암석", "형상": "화강암"}})
|
||
)
|
||
assert rock["배"] == Decimal("2.7") # 1 ㎥ = 2.7 톤(2,700 ㎏/㎥)
|
||
with pytest.raises(sd.DocError, match="0 보다"):
|
||
sd.clean(_doc("GF000099", "m", 환산={"계수": 0}), None, whole)
|
||
|
||
|
||
def test_식_빈_단위는_옛_셈(whole):
|
||
old = _shown(whole, _doc("GF000287", "식"))
|
||
assert old["배"] == 100 and round(old["1단위"]["계"], 2) == Decimal("2551.86")
|
||
assert "화면배" not in old and old["기준"]["계"] == Decimal("255186") # 화면 = 바탕 몫 그대로
|
||
|
||
|
||
def test_돈_아닌_기초_고르기_창에서_뺌(whole):
|
||
money = [
|
||
r
|
||
for tid, d in whole.index.items()
|
||
if tid in ("GC", "GF", "QC", "QF")
|
||
for r in d.values()
|
||
if isinstance(r, dict)
|
||
and "결과단위" in r
|
||
and not str(r["결과단위"]).strip().startswith("원")
|
||
]
|
||
assert len(money) == 65 # 지금 M01(785-7 · 옛 21 = M01 기초 늘기 전)
|
||
src = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Find_Pick.ts").read_text(encoding="utf-8")
|
||
assert '!logic.결과단위.trim().startsWith("원")' in src
|