- 「운반」 덧붙임 없앰 · 빈 항목명 = 거래처 · 그것도 없으면 묶음 이름 · 「운반」
- 자동 상자 둘째 행부터 `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
66 lines
3.1 KiB
Python
66 lines
3.1 KiB
Python
"""261-4 운반공 줄 이름 = 거리이정표 항목명 그대로(「운반」 안 붙임) · 행마다 개별 줄 · 단가연결 무관."""
|
|
|
|
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 # 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"}, {"item": "강모래", "dest": "mid"}]},
|
|
# 자동 상자 — 항목명 빈칸 · 거래처 없음 = 묶음 이름
|
|
{"id": "h-gravel", "name": "", "haul": "gravel", "via_base": False,
|
|
"legs": [], "rows": [{"item": "", "dest": "start"}]},
|
|
# 사용자 상자 — 「운반」 이 든 항목명 · 같은 이름 두 행 · 빈 항목명(거래처) · 연결 없음
|
|
{"id": "u1", "name": "석산", "via_base": False, "legs": [{"road": "포장", "km": 10}],
|
|
"rows": [{"item": "전석운반", "dest": "start"}, {"item": "전석운반", "dest": "start"},
|
|
{"item": " ", "dest": "start"}]},
|
|
# 사용자 상자 — 항목명 · 거래처 모두 빈칸 · 연결 있음
|
|
{"id": "u2", "name": "", "ref": LOGIC, "via_base": False, "legs": [],
|
|
"rows": [{"item": "", "dest": "start"}]},
|
|
],
|
|
} # fmt: skip
|
|
|
|
|
|
def _items() -> dict[str, dict]:
|
|
rows = haul_rows(DATA, compute_milestone(DATA, None))
|
|
return {i["key"]: i for i in haul_items(None, haul_user(rows)["haul_refs"], rows)}
|
|
|
|
|
|
def test_자동_상자_이름_항목명():
|
|
items = _items()
|
|
assert items["haul:3"]["name"] == "강모래"
|
|
assert items["haul:4"]["name"] == "자갈" # 항목 · 거래처 빈칸 = 묶음 이름
|
|
assert items["haul:1"]["name"] == "중기" # 상자 없음 = 묶음 이름
|
|
|
|
|
|
def test_자동_상자_둘째_행_개별_줄_묶음_바로_뒤():
|
|
items = _items()
|
|
keys = list(items)
|
|
assert keys.index("haul:3.1") == keys.index("haul:3") + 1
|
|
extra = items["haul:3.1"]
|
|
assert (extra["name"], extra["qty"], extra["dist"]["L2"]) == ("강모래", None, 2)
|
|
|
|
|
|
def test_사용자_상자_이름_항목명_같은_이름_두_줄():
|
|
items = _items()
|
|
assert items["haul:r-u1"]["name"] == items["haul:r-u1.1"]["name"] == "전석운반"
|
|
assert items["haul:r-u1.2"]["name"] == "석산" # 빈 항목명 = 거래처
|
|
assert items["haul:r-u2"]["name"] == "운반" and items["haul:r-u2"]["ref"] == LOGIC
|
|
assert items["haul:r-u1"]["ref"] is None # 연결 없어도 줄
|
|
|
|
|
|
def test_운반운반_없음():
|
|
assert not any("운반운반" in i["name"] for i in _items().values())
|