Merge remote-tracking branch 'origin/main_desktop_1' into main_laptop_1
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
"""새 구조물 기본값 — 「제안값 넣기」 걷음 · 생길 때 등록부 기본값을 칸에 실제 값으로 (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
|
||||
@@ -42,5 +42,6 @@ def test_TS_가_쓰는_칸이_파일에_있다() -> None:
|
||||
|
||||
|
||||
def test_B05_높이_칸은_제안_없이_설계자_입력() -> None:
|
||||
assert 'height: "",' in FIELDS and '"설계자 입력"' in FIELDS
|
||||
# 독립 기슭막이 높이 = 기본값 없음 · 「설계자 입력」 안내(제안값 단추 걷음 · PLAN 46-7)
|
||||
assert 'createRevetmentFields(keys, { height: "" })' in FIELDS and '"설계자 입력"' in FIELDS
|
||||
assert "기슭막이 높이 없음 — 근입만 그림" in CHROME
|
||||
|
||||
Reference in New Issue
Block a user