"""PLAN 472 덧 (요구 272) — 서버 상세 읽기 관 세트 = 측점 계획 · 화면과 같은 관 자리. 관 지점 정본의 노선 지문이 지금 노선과 어긋남(옛 노선 누가거리 394 · 좌표는 지금 노선 351) — 측점 계획(`_load_pipe_points`) · 관 지점 GET · 화면은 좌표로 351 에 얹는데 서버 상세 읽기 (`attach_saved_shapes`)만 파일 누가거리 394 로 찾아 351 측점에 관 세트를 못 붙였음(새로고침 = 관 세트 없음 · 관 지우기 ↶ = 화면이 다시 얹어 관 세트 있음 → 누가토량 갈림). ./venv/Scripts/python.exe -m pytest resources/tester/test_472_d_pipe_route_attach.py -q """ from __future__ import annotations import json import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT)) from B05_Profile.B05_Profile_Engine_Sections import ( # noqa: E402 _load_pipe_points, _load_route_polyline, ) from B06_Section.B06_Section_Engine_Attach import attach_saved_shapes # noqa: E402 ROUTE = "B05_Profile/route/route_main.geojson" def _project(root: Path) -> None: route = root / ROUTE route.parent.mkdir(parents=True) route.write_text( json.dumps( { "type": "Feature", "geometry": {"type": "LineString", "coordinates": [[0, 0, 0], [1000, 0, 0]]}, } ), encoding="utf-8", ) edits = root / "B04_PreProcess" / "drainage" / "edits" edits.mkdir(parents=True) pipe = { "id": "p35100", "chainage_m": 394.0, # 옛 노선 누가거리 "x": 351.0, "y": 0.3, "options": {"pipe_kind": "파형강관", "pipe_diameter_mm": "1000"}, } (edits / "pipe_points.json").write_text( json.dumps({"route_signature": "옛-노선", "points": [pipe]}), encoding="utf-8" ) def _sections() -> list[dict]: return [ {"chainage_m": at, "center_x": at, "center_y": 0.0, "structure": None} for at in (340.0, 351.0, 360.0, 380.0, 400.0) ] def test_상세_읽기_관_세트_자리_측점_계획과_같음(tmp_path: Path) -> None: _project(tmp_path) planned = _load_pipe_points(tmp_path, _load_route_polyline(tmp_path, ROUTE)) assert [round(p.chainage_m, 2) for p in planned] == [351.0] # 측점 계획 = 351 측점 sections = _sections() attach_saved_shapes(tmp_path, sections, ROUTE) owners = {s["chainage_m"]: s["culvert"]["chainage_m"] for s in sections if "culvert" in s} assert owners == {351.0: 351.0} def test_노선_경로_안_줌_노선_파일_하나(tmp_path: Path) -> None: # 472 덧(관 파일 누가거리 남은 자리) — 경로 안 줌 = 노선 파일 하나(`ROUTE_DATA_FILE`) · 옛 단언 # 「파일 누가거리 394」는 측점 계획과 갈리던 옛 동작이라 고침 _project(tmp_path) sections = _sections() attach_saved_shapes(tmp_path, sections) owners = {s["chainage_m"]: s["culvert"]["chainage_m"] for s in sections if "culvert" in s} assert owners == {351.0: 351.0} def test_노선_파일_없음_저장분_그대로(tmp_path: Path) -> None: _project(tmp_path) sections = _sections() attach_saved_shapes(tmp_path, sections, "B05_Profile/route/없음.geojson") assert not any("culvert" in s for s in sections)