- 박스암거 명세(design_structure_box) — 본체 규격 2.0×2.0 · 3.0×3.0 · 사용자 입력(가로 × 세로 숫자 칸) · 유입 · 유출 구조 없음 · 날개벽 · 흙막이 · 컨테이너마다 구조물 조합 잇기(gboxbody · gboxin · gboxout) - 저장 키 = 옛 키 그대로(body_width_m · body_height_m · wing_in · wing_out) · 규격 칸은 저장 안 함(폭 · 높이로 되찾음) · 옛 「있음」 = 날개벽 · 옛 날개벽 치수는 화면에서 빼고 지난 정의 값 - 명세 등록(STRUCTURE_SPECS) · 배관 시험 헬퍼가 같은 폴더 명세를 옮겨 읽음 - B06 날개벽 설치 판정 한 곳(wingInstalled) — 흙막이 = 날개벽 안 세움 · 저장 글을 있음/없음으로 안 덮음 · 날개벽 조정 행은 명세 유입 · 유출 칸으로 - 정의 판 7 — box_culvert 이름 표 · 그룹 셋 · wing_in/out 선택지 · 판 6 이력 보관 - 시험 test_52_structure_spec_box · 레지스트리 · 새 구조물 기본값 기대값 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
87 lines
3.8 KiB
Python
87 lines
3.8 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 test_새_관만_기본값_빈_키에만():
|
|
fresh = PipePoint(chainage_m=10.0, source="stream", options={"pipe_diameter_mm": 800})
|
|
basins._apply_new_defaults([fresh])
|
|
expected = {**_defaults("pipe"), "pipe_diameter_mm": 800} # 추천(먼저 들어간 값)이 이김
|
|
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 # 옛 빈칸 그대로
|
|
assert by[300.0].options == _defaults("pipe") # 새로 보충된 관 = 기본값
|
|
|
|
|
|
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_Drainage_Facility_Ford.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
|