- 오른쪽 글 상자 → 칸 차례(거리 · 사이클 8-2-8 · 단가산출) · 칸마다 제목 · 몸 · 바닥 결과 - 사이클 칸 = Cm · 사이클시간 · t2 받는 로직만 · 조합 = 담은 로직 줄마다 미리보기 · 하위 산근 이어 붙임 - logic-preview 응답에 blocks(머리 · 호표 줄 · 계 · 출처) 더함 · 셈 · lines 그대로 - 값 칸 숫자 칸 = ui-input--sm(고르기 칸과 같은 높이) · 「거리에서」 → 「자동계산」 단추 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Se7ytqbohmBQnfYpwYFnYf
63 lines
2.7 KiB
Python
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", "openPriceLink", "fetchLogicInputs", "fillGiven",
|
|
"cycleInputs", "my !== seq", "자동계산", "[고르기]"): # 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 && ref ? haulModal : priceLink]]' in link # 276 연결 있는 줄만
|
|
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
|
|
)
|