Files
Aislo/resources/tester/test_b05_pipe_station_relabel.py
T
eomsangdonandClaude Opus 5.5 1e02ecc196 fix(structure): 관 지점 시설 종류 바꾸기 뒤 B06 횡단도 · 알약 · 목록 바로 새 종류(54-4)
- 좌측 패널 종류 바꿈 = 고른 관 지점 실시간 반영
- B06 관 고침이 시설 종류를 받음 · 옛 종류 칸 안 이음 · 알약 · 횡단 다시 그림
- 횡단 상세 읽기에 초안 종류 얹기(짝 산식 common_util_culvert_sets) · 카드 제목 라벨 포함
- 상세 조회가 측점 라벨을 지금 관 지점 종류로(저장 뒤 다시 열기)
- 구조물 다시 그림 최신 요청만 채택
- 시험: test_b05_pipe_station_relabel · ui_checks 54-4_종류바꾸기_횡단

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rJwJMVL4EE31y77TB11AP
2026-10-06 10:26:34 +09:00

75 lines
2.8 KiB
Python

"""54-4 — 저장으로 관 지점 종류만 바꾸면 횡단 측점 라벨(카드 제목)이 새 종류를 따라감.
측점은 다시 안 만들어지므로 라벨은 파일에 옛 종류로 남음 — 상세 조회가 지금 관 지점으로 고침.
다른 구조물 라벨(옹벽 등)은 건드리지 않음.
"""
import json
from B05_Profile.B05_Profile_Engine_Sections import relabel_pipe_stations, resolve_extra_stations
from common_util.common_util_drainage_pipes import parse_pipe_points
def _write_points(root, points):
edits = root / "B04_PreProcess" / "drainage" / "edits"
edits.mkdir(parents=True, exist_ok=True)
(edits / "pipe_points.json").write_text(json.dumps({"points": points}), encoding="utf-8")
def _sections():
return [
{"chainage_m": 80.0},
{"chainage_m": 85.05, "structure": "파형강관 D900"},
{"chainage_m": 120.0, "structure": "옹벽"},
{"chainage_m": 173.09, "structure": "세월교"},
{"chainage_m": 258.12, "structure": "파형강관 D800"},
]
def test_relabel_follows_saved_kind(tmp_path):
_write_points(
tmp_path,
[
{"chainage_m": 85.05, "source": "spacing", "facility": "box_culvert"},
{"chainage_m": 120.0, "source": "user", "facility": "box_culvert"}, # 옹벽 라벨 자리
{
"chainage_m": 173.09,
"source": "stream",
"facility": "pipe",
"options": {"pipe_kind": "흄관", "pipe_diameter_mm": 1200},
},
{"chainage_m": 258.12, "source": "spacing", "facility": "ford_pavement"},
],
)
sections = _sections()
relabel_pipe_stations(tmp_path, sections)
labels = {s["chainage_m"]: s.get("structure") for s in sections}
assert labels == {
80.0: None,
85.05: "BOX암거",
120.0: "옹벽", # 관 지점 라벨이 아닌 측점은 그대로
173.09: "흄관 D1200",
258.12: None, # 물넘이포장 = 라벨 없음(측점 생성 규칙과 같음)
}
def test_relabel_matches_generation_rule(tmp_path):
points = [
{"chainage_m": 85.05, "source": "spacing", "options": {"pipe_diameter_mm": 1000}},
{"chainage_m": 173.09, "source": "stream", "facility": "ford_bridge"},
]
_write_points(tmp_path, points)
sections = [
{"chainage_m": 85.05, "structure": "세월교"},
{"chainage_m": 173.09, "structure": "BOX암거"},
]
relabel_pipe_stations(tmp_path, sections)
generated = dict(resolve_extra_stations(tmp_path, parse_pipe_points(points)))
assert [s["structure"] for s in sections] == [generated[85.05], generated[173.09]]
def test_relabel_without_file_keeps_labels(tmp_path):
sections = _sections()
relabel_pipe_stations(tmp_path, sections)
assert sections == _sections()