Files
Aislo/resources/tester/test_728_2_sk_unit.py
T
eomsangdonandClaude Opus 5.5 ced5233c09 refactor(855-2-C1): 단가산출 셈 한 길 — 줄 · 비목 · 끝수 · 기준 모두 수식 사본 문서 셈 · 옛 엔진(run_line) 안 돎
- `Sangeun_Calc.run` = 수식 사본 문서 셈 답으로 답 꼴 채움(기준 · 1단위 · 배 · 줄 cid 「금액#n」 · 단위 · 끝수 · 까닭 · 수식셈 · 바탕판 · 꼬리표) · 빠진줄 · 짝잃음 = 빈 목록(옛 칸 개념)
- 수식 사본 없는 SK(바탕 참조) · 옛 칸 고침 파생 SK(덮개 · 뺀줄 · 더한줄 · 수식고침 · 식 칸) = 못 셈 + 까닭 하나(올림 없음) · `sub_run`(둘째 기초) 도 못 셈
- 굳힌 사본 SK(B09 · 구조물 사본 GX9 · 수식 없음) = 옛 길 그대로(`_frozen` · B9 걸음 몫)
- `Doc_Sk.derive` = 옛 엔진 ctx 없이 기초 문서 사본 + 줄 규칙(입력값 · 켜쌓기율 · 고름 · 자재표시) · `copy_of(sk, whole)` · `on_run` 걷음 · 저장 `settle` = 옛 셈 안 돎 · 저장 관문 읽은 줄 = 문서 셈 + 부름 줄(826-3) · 저장 전 새 SK = 지금 M01 값 · 열린 목록 · 내 기계 고른 값 = 목록에 더함
- `Doc_Sk_Path.current` · `Labor_Copy.line`(사본 있으면 문서만) · `Doc_Import._old_ctx` 걷음(엔진 더한줄 = 못 셈) · `Sangeun_Const.answer` 보기 덧칸 없음
- 층 서고 SK 14 전후: 기준 · 1단위 · 배 · 까닭 · 바탕판 다름 0 · 줄 합 = 기준 11/14 → 14/14 · 「따로」 줄 0 → 4 · 한 번 셈 run_line 14 → 0(저장 25 → 0)
- 시험: test_855_sk_layers 「따로」 단언 뒤집음(줄 합 = 기준 · 줄 > 0 · 옛 엔진 부름 0 · 옛 칸 = 못 셈) · golden_855_b09 다시 뜸(daega_inputs — 「율 더한줄」 SK = 옛 칸 = 못 셈 → 그 블록 m02 없음 · 그 밖 같음)
- 지운 시험(옛 칸 셈만 붙듦 — 덮개 · 뺀줄 · 더한줄 · 율 더한줄 · 수식고침 · 식 칸 · 상수 · 표값 덮개 · 넣은 SK 몸 · 줄 패치 · 보기 글 · 옵션꺼짐 줄): 715_sangeun_engine · 717_2b · 725_1 · 744_1 · 750_1 파일 · 715_3 셋 · 715_store 다섯 · 727 넷 · 728_2 하나 · 740_1 일곱 · 742_1 하나 · 753_1 하나 · 778_4 여섯 · 790_2 다섯 · 792_1 일곱 · 792_2 하나 · 795_1 하나 · 795_2 하나 · 796_2b 셋 · 822_1 하나 · logic_mats 둘(일위대가 옛 로직 줄 재료 목록 — 사본 셈 = 문서)
- 고친 시험(살아 있는 결과): 728_2 금액 = 수식 문서 기본 옵션 · 747_1 줄 이름 · 별도계상 합밖 · 721 일위대가 쪽만 · 793_2 옛 시트 같음 단언 둘 뺌 · 795_1 노임 키 = 값 사본 · 802_4a · 802_4b2 부름 = 기초 문서가 부르는 단가산출(GC000006) · 811_1 모달 저장 = 수식 길 · 821_1 · 822_2 · 778_2 = 바탕 로직 + 입력값 · 826_3 저장 셈 1 → 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:15:10 +09:00

92 lines
3.7 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.
"""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)
assert sc.head_of({"단위": "100본"}) == "100본 당"
one = _shown(whole, _doc("GF000287", "본"))
assert one["배"] == 100 and round(one["기준"]["계"], 2) == Decimal("2551.86")
assert sc.head_of({"단위": "본"}) == "1 본 당"
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