- 「운반」 덧붙임 없앰 · 빈 항목명 = 거래처 · 그것도 없으면 묶음 이름 · 「운반」
- 자동 상자 둘째 행부터 `haul:{묶음}.n` 개별 줄(묶음 줄 바로 뒤 · 수량 빈칸)
- 시험 기대값 고침(253_1 · 251_1 · 145_3) · 새 시험 test_261_4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JywHxQuWPk6UYXTebyrBoU
61 lines
2.7 KiB
Python
61 lines
2.7 KiB
Python
"""253-1 거리이정표 행 1:1 → B09 운반공 줄 — 자동 상자 = 옛 키 · 사용자 상자 = `haul:r-{id}`."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
|
|
|
from B08_Quantity.B08_Quantity_Haul import haul_rows, route_bill_key # noqa: E402
|
|
from B08_Quantity.B08_Quantity_Milestone_Calc import compute_milestone # noqa: E402
|
|
from B09_Estimation.B09_Estimation_Bill_Items import haul_items # noqa: E402
|
|
from B09_Estimation.B09_Estimation_Router import haul_user # noqa: E402
|
|
|
|
LOGIC = {"tab": "logic", "code": "GF000134", "name": "골재운반", "given": {}}
|
|
DATA = {
|
|
"site": {"mid_station_m": 2000, "mid_road": "비포장"},
|
|
"base": {"enabled": False, "legs": []},
|
|
"routes": [
|
|
{"id": "h-sand", "name": "골재상", "haul": "sand", "via_base": False,
|
|
"legs": [{"road": "포장", "km": 25.1}], "rows": [{"item": "모래", "dest": "start"}]},
|
|
{"id": "u1", "name": "석산", "ref": LOGIC, "via_base": False,
|
|
"legs": [{"road": "포장", "km": 10}, {"road": "비포장", "km": 0.8}],
|
|
"rows": [{"item": "혼합골재", "dest": "start"}, {"item": "깬돌", "dest": "mid"}]},
|
|
],
|
|
} # fmt: skip
|
|
|
|
|
|
def test_keys():
|
|
assert route_bill_key({"id": "h-sand", "haul": "sand"}) == "haul:3"
|
|
assert route_bill_key({"id": "h-x", "haul": "remicon"}) == "haul:remicon"
|
|
assert route_bill_key({"id": "u1"}) == "haul:r-u1"
|
|
assert route_bill_key({"id": "u1"}, 1) == "haul:r-u1.1"
|
|
|
|
|
|
def test_rows_one_per_table_row():
|
|
rows = haul_rows(DATA, compute_milestone(DATA, None))
|
|
got = {r["key"]: r for r in rows}
|
|
assert list(got) == ["haul:3", "haul:r-u1", "haul:r-u1.1"]
|
|
assert (got["haul:3"]["L1"], got["haul:3"]["L2"], got["haul:3"]["user"]) == (25.1, 0, False)
|
|
assert (got["haul:r-u1"]["name"], got["haul:r-u1"]["L1"], got["haul:r-u1"]["L2"]) == (
|
|
"혼합골재", 10, 0.8) # fmt: skip 261-4 항목명 그대로
|
|
assert got["haul:r-u1.1"]["L2"] == 2.8 # 중점 = 시점 → 중점 2 km 비포장 더함
|
|
assert got["haul:r-u1"]["ref"] == LOGIC
|
|
|
|
|
|
def test_bill_items_user_rows():
|
|
rows = haul_rows(DATA, compute_milestone(DATA, None))
|
|
extra = haul_user(rows)
|
|
items = {i["key"]: i for i in haul_items(None, extra["haul_refs"], rows)}
|
|
assert (
|
|
"haul:3" in items and items["haul:3"]["name"] == "모래"
|
|
) # 자동 = 상자 항목명(261-4)
|
|
user = items["haul:r-u1"]
|
|
assert (user["section"], user["name"], user["qty"], user["ref"]) == (
|
|
"3",
|
|
"혼합골재",
|
|
None,
|
|
LOGIC,
|
|
)
|
|
assert items["haul:r-u1.1"]["name"] == "깬돌" and items["haul:r-u1.1"]["ref"] == LOGIC
|
|
assert extra["haul_dist"]["haul:r-u1"] == {"L1": 10, "L2": 0.8}
|