Files
Aislo/resources/tester/test_253_3_haul_preview.py
T
eomsangdonandClaude Opus 5.5 cb2db4ff49 feat(b09): 운반 단가 모달 · 로직 미리보기 길 (253-3)
- POST /api/projects/{id}/estimation/logic-preview — 로직 한 산근을 프로젝트 단가로 풀어 계산 절차 글 · 단가(저장 안 함)
- 「운반 단가」 모달 — 단가산출 이름 · [변경] · [다른 종류] · 옵션 값(로직 입력 + 사이클 입력 · 표 고르기 CC000054~058) · 계산 절차(사이클 식 + 미리보기)
- 여는 곳 = B08 거리이정표 표 우클릭 [단가연결] · B09 설계내역서 운반공 줄 단가연결 · 운반 항목에 거리(dist)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JywHxQuWPk6UYXTebyrBoU
2026-10-11 14:10:38 +09:00

63 lines
2.7 KiB
Python

"""253-3 미리보기 길 `POST …/estimation/logic-preview` + 「운반 단가」 모달 — 거리이정표 우클릭 ·
설계내역서 운반공 줄에서 엶."""
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from B08_Quantity.B08_Quantity_Haul_Cycle import cycle_time # noqa: E402
from B09_Estimation.B09_Estimation_Bill_Items import haul_items # noqa: E402
from B09_Estimation.B09_Estimation_Router import PreviewBody, logic_preview, router # noqa: E402
def _src(name: str) -> str:
return (ROOT / name).read_text(encoding="utf-8")
def test_미리보기_계산_절차(tmp_path):
cm = cycle_time({"L1": 25.1, "L2": 0.8})["cm"]
given = {"qt": 15, "f": 1, "E": 0.9, "Cm": cm, "지역": "전국평균"}
got = logic_preview(tmp_path, PreviewBody(code="GF000134", given=given))
assert got["unit"] == "㎥" and got["price"] and got["price"] > 0
assert "Cm : 109.78 분" in got["lines"]
assert any("60 * 15 * 1 * 0.9 / 109.78" in line for line in got["lines"])
assert got["lines"][-1].startswith("계 :")
# 거리 늘면 단가도 늘음
far = logic_preview(tmp_path, PreviewBody(code="GF000134", given={**given, "Cm": 200}))
assert far["price"] > got["price"]
def test_미리보기_길():
paths = {(r.path, tuple(r.methods)) for r in router.routes}
assert ("/api/projects/{project_id}/estimation/logic-preview", ("POST",)) in paths
def test_내역_줄_거리():
one = {"ref": None}
routes = [
{**one, "key": "haul:3", "name": "모래운반", "user": False, "L1": 25.1, "L2": 0.8},
{**one, "key": "haul:r-u1", "name": "깬돌운반", "user": True, "L1": 3, "L2": 1},
]
items = {i["key"]: i for i in haul_items(None, {}, routes)}
assert items["haul:3"]["dist"] == {"L1": 25.1, "L2": 0.8}
assert items["haul:r-u1"]["dist"] == {"L1": 3, "L2": 1}
assert items["haul:1"]["dist"] is None
def test_모달_여는_곳():
modal = _src("B09_Estimation/B09_Estimation_UI_Haul_Modal.ts")
for want in ("/estimation/logic-preview", "openLogicPicker", "fetchLogicInputs", "fillGiven",
"cycleInputs", "my !== seq", "CC000054", "거리에서", "[고르기]"): # fmt: skip
assert want in modal, want
milestone = _src("B08_Quantity/B08_Quantity_UI_Milestone.ts")
assert "openHaulModal({" in milestone and "L1: paved" in milestone
link = _src("B09_Estimation/B09_Estimation_UI_Tabs_Bill_Link.ts")
assert '[["단가연결", haul ? haulModal : priceLink]]' in link
edit = _src("B09_Estimation/B09_Estimation_UI_Tabs_Bill_Edit.ts")
assert (
'key.startsWith("haul:")' in edit
and "linkItems(ctx, ref, applyRef(ctx, rows, i), haul)" in edit
)