Files
Aislo/resources/tester/test_143_2_b08_blank_values.py
T
eomsangdonandClaude Opus 5.5 e4b9b3e5a3 refactor(859-5 ②): 구조물 정의 코드 M02 StructOptions → M01_MasterData/StructOptions
- 파일 23 개 git mv · 이름 M02_SO_* → M01_SO_* · 내용 · 동작 · 화면 글 그대로
- 서버 주소 /api/m02 → /api/m01(이름만 · 10 길 · 수 469 그대로) · main.py 등록 이름 m01_so_*
- 화면 부름 = common_util_m02_call 의 call 에 base 인자(기본 /m02 · 구조물 정의만 /m01)
- import 고침 = B05 · B07 · B08 · M01 · M02 · main · 시험 · 도우미
- 소스 글자만 보던 시험 셋 지움(구조물 정의 옮김에 걸림 · 결과를 안 봄):
  test_m02_structure_options 좌측 줄 · test_m02_structure_option_groups 좌측 정의 줄 · test_136_3 M02 미리보기 단추 CSS
- test_553_5 부품 훑기 폴더 = 옮긴 자리

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 21:42:33 +09:00

81 lines
3.1 KiB
Python

# -*- 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 M01_MasterData.StructOptions import M01_SO_Definition as definition
from M02_MasterTemplete import M02_Item_Snapshot as snapshots
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"]