Files
Aislo/resources/tester/test_b05_pipe_station_relabel.py
T
eomsangdonandClaude Opus 5.5 04d16e0e2f feat(b05,b06): 물넘이포장도 종단 기준 측점 하나 심음 — TS · 파이썬 짝 · B05 · B06 거름 걷음 (286-1)
- pipeStationMarks · pipe_station_label 물넘이포장 예외 걷음 · 라벨 「물넘이포장」
- B05 withoutFordPavement · B06 pipeStations · 초안 라벨 거름 걷음 · 알약 = 그 측점선 짝
- 시험 test_286_1 새로 · 272_1 · 284_1 · 옛 물넘이 측점 시험 기대값 새 규칙으로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
2026-10-12 20:03:11 +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: "물넘이포장", # 물넘이포장도 종류 이름(286-1 · 측점 생성 규칙과 같음)
}
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()