- 별칭(master_material) · 같은 성격 환산(master_pick) · 결과단위 배 읽기 셋(Store_Combo · Hopyo_Ours · master_basis) · 보이는 꼴 별칭(master_basis) 갈아 끼움 · 엑셀 맞춤(Hopyo_Match)은 master_pick 이름 그대로 이음 - 개수 묶음(개 · EA · 본 · 매) 1:1 — 본 ↔ 개 단위경고 4 줄 사라짐 · 값 같음 - 부피 ↔ 무게 = 단위중량 표 CC000337 고른 줄 받을 때만(기본 줄 없음) · 밀도 · ㎾h 경고 글만 - B08 /1000 · /40 손 식 = 실무 엑셀 G열 식이라 그대로(시험이 같은 값 대조) - 지킴 시험 test_712_2_unit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.6 KiB
Python
60 lines
2.6 KiB
Python
"""712-2 지킴 — 단위 한 벌(`master_unit`) · 다섯 자리가 같은 모듈을 씀 · 알약 배 전수."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import sys
|
||
from decimal import Decimal
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parents[2]
|
||
sys.path.insert(0, str(ROOT / "resources/master_data/scripts"))
|
||
sys.path.insert(0, str(ROOT))
|
||
|
||
import check_master as cm # noqa: E402
|
||
import master_basis as mbs # noqa: E402
|
||
import master_formula as mf # noqa: E402
|
||
import master_material as mm # noqa: E402
|
||
import master_pick as mp # noqa: E402
|
||
import master_unit as mu # noqa: E402
|
||
|
||
|
||
def test_alias_and_count_group():
|
||
assert mu.plain("EA") == mu.plain("ea") == "개"
|
||
assert mu.plain("Ton") == mu.plain("t") == mu.plain("톤") == "톤"
|
||
assert mu.plain("㎥") == "m3" and mu.plain("리터") == mu.plain("ℓ") == "ℓ"
|
||
assert mu.same_kind("본", "개") and mu.same_kind("매", "EA")
|
||
assert not mu.same_kind("조", "개") # 한 조 = 여럿 — 묶음 밖
|
||
assert mu.note("본", "개") == "본 = 개(개수 1:1)"
|
||
assert mm.plain_unit("EA") == mu.plain("EA")
|
||
assert mp.convert is mu.convert and mp.UNITS is mu.UNITS
|
||
|
||
|
||
def test_same_kind_convert():
|
||
assert mu.convert(Decimal(1000), "톤", "kg") == Decimal(1) # 톤 당 1000 원 = kg 당 1 원
|
||
assert mu.convert(Decimal(5), "kg", "톤") == Decimal(5000)
|
||
assert mu.convert(Decimal(7), "m", "km") == Decimal(7000)
|
||
assert mu.factor("kg", "ton") == Decimal("0.001") # B08 「/1000」(kg → ton) 손 식과 같은 값
|
||
assert mu.note("kg", "톤") == "kg → 톤 ×1000"
|
||
assert mu.convert(Decimal(3), "kg", "ℓ") == Decimal(3) # 밀도 = 경고만 · 그대로
|
||
assert "성격 다름" in mu.note("ℓ", "㎾h")
|
||
|
||
|
||
def test_volume_weight_only_when_picked():
|
||
"""부피 ↔ 무게 = 단위중량 표 고른 줄이 있을 때만 · 기본 줄 없음."""
|
||
master = mf.Master(cm.load())
|
||
assert mu.factor("㎥", "톤") is None
|
||
assert "단위중량(CC000337)" in mu.note("㎥", "톤")
|
||
rho = mu.unit_weight(master, "모래", "건조")
|
||
assert rho is not None and rho > 1000
|
||
assert mu.factor("㎥", "톤", rho) == rho / 1000 # 1 ㎥ = ρ/1000 톤
|
||
assert mu.convert(Decimal(100), "㎥", "톤", rho) == Decimal(100) * 1000 / rho
|
||
assert mu.unit_weight(master, "없는 종별", "건조") is None
|
||
|
||
|
||
def test_result_per_one_parser():
|
||
assert mu.per("원/10㎡") == [(Decimal(10), "㎡")]
|
||
assert mu.per("원/1,000본") == [(Decimal(1000), "본")]
|
||
assert mu.per("원/㎡ · 원/㎥(단위 따름)") == [(Decimal(1), "㎡"), (Decimal(1), "㎥")]
|
||
assert mu.per("㎥/시간") == []
|
||
assert mbs.result_per("원/ton") == [(Decimal(1), "ton")]
|