# -*- coding: utf-8 -*- """B08 구조물 집계표 — 관경 · 련 빈칸 = 「미입력」(임의 1000 · 1 로 안 채움 · PLAN 143-2). 견본: 100 관 관경 빈칸 L16 · 유출 흙막이 높이 빈칸 / 200 세월교 Φ1000 련 빈칸 · 관 길이 9. """ from __future__ import annotations import json from pathlib import Path from B08_Quantity import B08_Quantity_Router_Summary as summary from M02_MasterTemplete import M02_Item_Snapshot as snapshots from M02_MasterTemplete.StructOptions import M02_SO_Definition as definition ITEM = {"layer": "system", "owner": None, "key": "SS000001", "name": "견본"} POINTS = [ { "chainage_m": 100.0, "options": { "pipe_diameter_mm": "", "outlet_type": "기슭막이", "outlet_revet_form": "돌쌓기(메)", "outlet_revet_before_m": 5, "outlet_revet_after_m": 5, }, "summary_item": ITEM, "group_items": {"g9lq9uk": ITEM}, }, { "chainage_m": 200.0, "facility": "ford_bridge", "options": {"pipe_diameter_mm": 1000, "pipe_count": "", "ford_width_m": 12}, "summary_item": ITEM, }, ] DESIGNS = [ {"chainage_m": 100.0, "design": {"pipe_length_m": 16}}, {"chainage_m": 200.0, "design": {"ford_pipe_length_m": 9}}, ] def _run(tmp_path: Path) -> dict: root = tmp_path / "proj" edits = root / "B04_PreProcess/drainage/edits" edits.mkdir(parents=True) points = [{**p, "source": "user"} for p in POINTS] (edits / "pipe_points.json").write_text( json.dumps({"points": points}, ensure_ascii=False), encoding="utf-8" ) names = definition.read()["종류"]["pipe"]["이름"] linked = {owner: {} for owner in snapshots.assignments(root)} return summary.pipe_summary(root, DESIGNS, names, 6.0, linked=linked) def _cell(out: dict, at: float, cid: str): row = next(r for r in out["rows"] if abs(r["chainage_m"] - at) < 0.01) return row["values"].get(cid) def test_관경_빈칸은_미입력_열(tmp_path): out = _run(tmp_path) cols = {c["id"]: c for c in out["columns"]} assert cols["pipe:len|-"]["group"] == ["관 공", "미입력", "관매설"] assert _cell(out, 100, "pipe:len|-") == 16 assert _cell(out, 100, "pipe:cp|-") == 2 # 1본 6 m — 관경과 무관 assert not any(c.startswith("pipe:len|1000") and _cell(out, 100, c) for c in cols) # 흙막이 빈 높이 = 관경 최소 높이를 모름 → 「미입력」 assert cols["pipe:revet|돌쌓기(메)|-"]["group"][2] == "미입력" assert _cell(out, 100, "pipe:revet|돌쌓기(메)|-") == 10 def test_세월교_련_빈칸은_미입력_관_몫_빈칸(tmp_path): out = _run(tmp_path) cols = {c["id"]: c for c in out["columns"]} assert cols["pipe:ford|1000|-|width"]["group"][1] == "Φ1000×미입력련" assert _cell(out, 200, "pipe:ford|1000|-|width") == 12 assert _cell(out, 200, "pipe:len|1000") is None # 련 수를 모르면 관 몫도 빈칸 assert _cell(out, 200, "pipe:cp|1000") is None assert not [p for p in out["pipes"] if p["column"] == "pipe:cp|1000"]