- `_apply_new_defaults` — 집수정 갈래면 `inlet_revet_*` 기본값 · 높이 안 채움 · `inlet_basin_animal` "true" · 등록부 관경 글 "1000" → 수 - 새 자동 관이 폼을 처음 거쳐도 파일이 안 바뀜(620 증상) · 옛 프로젝트 이주 없음 - 시험 — 새 `test_623_inlet_defaults`(폼 왕복 차 0 · `helper_623_inlet_defaults.cjs`) · 기대값 고침 `test_b05_new_structure_defaults` · `test_211_1`(기슭막이 관으로) · `test_b05_drainage_recommend`(관경 수) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
4.5 KiB
Python
98 lines
4.5 KiB
Python
"""새 구조물 기본값 — 「제안값 넣기」 걷음 · 생길 때 등록부 기본값을 칸에 실제 값으로 (PLAN 46-7).
|
|
|
|
못박는 것
|
|
- 자동 배치로 새로 놓인 관 = 등록부 기본값을 빈 키에 채움 · 추천 관경이 기본값을 이김.
|
|
- 이미 있던 관(원본에 있던 자리)의 빈 칸은 그대로(옛 프로젝트 빈칸 = 미확정 유지).
|
|
- 월류 폭 기본값(세월교 10 · 물넘이 5)은 등록부에 · 엔진 상수와 같음.
|
|
- 화면: 제안값 단추 · 「제안 …」 글이 없음 · 값 없이 그리면 등록부 기본값(`newDefaults`).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from B04_PreProcess import B04_PreProcess_Router_Basins as basins
|
|
from B05_Profile.B05_Profile_Structures_Schema import structure_type_map
|
|
from B06_Section.B06_Section_Engine_Culvert import (
|
|
FORD_DEFAULT_WIDTH_M,
|
|
FORD_PAVEMENT_DEFAULT_WIDTH_M,
|
|
)
|
|
from common_util.common_util_drainage_pipes import PipePoint
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def _defaults(type_id: str) -> dict:
|
|
return {
|
|
o.key: o.default
|
|
for o in structure_type_map()[type_id].options
|
|
if o.default not in (None, "")
|
|
}
|
|
|
|
|
|
def _basin_defaults() -> dict:
|
|
"""새 관(유입 집수정) — 유입 흙막이 칸 없음 · 모양 L · 동물이동형 유 · 관경 수(623)."""
|
|
kept = {k: v for k, v in _defaults("pipe").items() if not k.startswith("inlet_revet_")}
|
|
return {**kept, "pipe_diameter_mm": 1000, "inlet_structure": "L", "inlet_basin_animal": "true"}
|
|
|
|
|
|
def test_새_관만_기본값_빈_키에만():
|
|
fresh = PipePoint(chainage_m=10.0, source="stream", options={"pipe_diameter_mm": 800})
|
|
basins._apply_new_defaults([fresh])
|
|
# 추천(먼저 들어간 값)이 이김 · 집수정 모양 L 도 실제 값(54-39)
|
|
# 관 보호공 · 유입 집수정 높이 = 관경 + 0.5(139-1 · Φ800 → 1.3) · 집수정이면 유입 흙막이 없음(623)
|
|
heights = {"outlet_revet_height_m": 1.3, "inlet_basin_height_m": 1.3}
|
|
expected = {**_basin_defaults(), "pipe_diameter_mm": 800, **heights}
|
|
assert fresh.options == expected
|
|
assert fresh.options["pipe_kind"] == "파형강관" and fresh.options["inlet_type"] == "집수정"
|
|
box = PipePoint(chainage_m=20.0, source="stream", facility="box_culvert")
|
|
basins._apply_new_defaults([box])
|
|
assert box.options["body_width_m"] == 2.0 and box.options["wing_in"] == "날개벽"
|
|
|
|
|
|
def test_원본에_있던_관은_빈칸_그대로(monkeypatch):
|
|
"""`_build` — 원본 목록에 있던 자리는 기본값을 안 받고, 새 자리만 받음."""
|
|
|
|
class Pipe:
|
|
def __init__(self, chainage_m: float, reason: str) -> None:
|
|
self.chainage_m, self.reason = chainage_m, reason
|
|
|
|
class Detail:
|
|
pipes = [Pipe(100.0, "stream"), Pipe(300.0, "spacing")]
|
|
basins: list = []
|
|
|
|
monkeypatch.setattr(basins, "build_detail", lambda *_: Detail())
|
|
monkeypatch.setattr(basins, "drainage_dir", lambda _: "x")
|
|
|
|
class Ctx:
|
|
vertices: list = []
|
|
|
|
old = PipePoint(chainage_m=100.0, source="stream") # 옛 관 — 옵션 없음
|
|
_, points = basins._build("p", Ctx(), [old])
|
|
by = {p.chainage_m: p for p in points}
|
|
assert by[100.0].options is None # 옛 빈칸 그대로
|
|
# 새로 보충된 관 = 기본값 + 집수정 모양 L(54-39) · 동물이동형 유 · 유입 흙막이 없음(623)
|
|
# 기본 관경 1000 → 1.5(139-1)
|
|
heights = {"outlet_revet_height_m": 1.5, "inlet_basin_height_m": 1.5}
|
|
assert by[300.0].options == {**_basin_defaults(), **heights}
|
|
|
|
|
|
def test_월류_폭_기본값은_등록부_엔진과_같음():
|
|
assert _defaults("ford_bridge")["ford_width_m"] == FORD_DEFAULT_WIDTH_M
|
|
assert _defaults("ford_pavement")["ford_width_m"] == FORD_PAVEMENT_DEFAULT_WIDTH_M
|
|
|
|
|
|
def test_화면에_제안값_단추_제안_글이_없음():
|
|
files = [
|
|
"B05_Profile/B05_Profile_UI_Drainage_Facility.ts",
|
|
"B05_Profile/B05_Profile_UI_Drainage_Facility_Fields.ts",
|
|
"B05_Profile/B05_Profile_UI_Structures_Fields.ts",
|
|
"B05_Profile/B05_Profile_UI_Structures_Panel_Options.ts",
|
|
]
|
|
for name in files:
|
|
text = (ROOT / name).read_text(encoding="utf-8")
|
|
assert "제안값 넣기" not in text and "b05-structure__suggest" not in text, name
|
|
assert "`제안 " not in text and '"제안 ' not in text and "(제안 " not in text, name
|
|
panel = (ROOT / "B05_Profile/B05_Profile_UI_Structures_Panel.ts").read_text(encoding="utf-8")
|
|
assert "values ?? newDefaults()" in panel and "options ?? newDefaults()" in panel
|