- 관 지점 정본 지문이 지금 노선과 어긋난 저장분(검증_sub4 · 파일 394 · 좌표 351) — 측점 계획(_load_pipe_points) · GET 은 351 에 얹고 서버 상세 읽기(attach_saved_shapes)만 파일 누가거리로 찾아 351 관 세트 빠짐 → 새로고침 = 관 세트 없음 · 관 지움 ↶ = 화면이 다시 얹어 관 세트 있음(누가토량 갈림) - saved_pipes(노선 경로) — 상세 GET · 재생성 응답 · 설계 미리보기가 노선 경로를 넘김 · 노선 못 읽으면 저장분 그대로 - 시험 test_472_d_pipe_route_attach(옛 코드 실패) · golden 헬퍼도 같은 읽기 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.0 KiB
Python
85 lines
3.0 KiB
Python
"""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:
|
|
_project(tmp_path)
|
|
sections = _sections()
|
|
attach_saved_shapes(tmp_path, sections) # 노선 경로 없음 = 파일 누가거리(394 · 제 측점 없음)
|
|
assert not any("culvert" in s for s in sections)
|
|
|
|
|
|
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)
|