Files
Aislo/resources/tester/test_512_1_b07_basin_contour.py
T
eomsangdonandClaude Opus 5.5 c2ed0fad54 feat(512-1 B07 유역도 등고선 간격): 유역도 등고선 5 m 기본 · 평면도 관리 모달에서 10 m 고름(1 m 없음 · B05 · B06 전용) — 요구 326
- 원인 확인: 유역도 23 MB = 1 m 아님 · 도엽 N3L 5 m 주곡선 그대로(등고선 층이 응답 대부분)
- 유역도 종류 파일 contour_interval_m(5 · 10) · 배경선 = 간격 배수 높이만 · 10 m = 23.17 → 11.91 MB
- 지문: 종류 목록 지문에서 간격 뺌 → 간격 바꾸면 유역도만 다시 받음 · 기본 종류 조각 차례 맞춤(파일로 내려도 지문 그대로)
- 시험: test_512_1_b07_basin_contour 새로 · test_b07_plan_kinds · helper_130 새 칸 · test_cad_host_tabs 508-1f 뒤 ☰ 자리 단언 고침

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:56:06 +09:00

100 lines
4.1 KiB
Python

# -*- coding: utf-8 -*-
"""512-1 B07 유역도 등고선 간격 5 m 기본 · 종류 옵션 10 m(임시 폴더 · DB · 실제 마스터 안 씀).
- 배경선 = 간격 배수 높이만(높이 없는 선은 남김 · None = 전부)
- 유역도 종류 = contour_interval_m 5 기본 · 10 고름 · 1 거절 · 평면도 양식엔 칸 없음
- 지문 = 간격 바꾸면 유역도만 · 기본 종류를 파일로 내려도 그대로 · 같은 값 = 같은 지문
./venv/Scripts/python.exe -m pytest resources/tester/test_512_1_b07_basin_contour.py -q
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from B07_DesignDetail import B07_DesignDetail_Router_Support_Fingerprint as fp # noqa: E402
from B07_DesignDetail.B07_DesignDetail_Router_Support_Basin import _metric_lines # noqa: E402
from B07_DesignDetail.B07_DesignDetail_Router_Support_Plan import ( # noqa: E402
list_kinds,
update_kind,
)
def _line(level: float | None, x: float) -> dict:
props = {} if level is None else {"등고수치": level}
coords = [[x, 0.0], [x, 1.0]]
return {"properties": props, "geometry": {"type": "LineString", "coordinates": coords}}
def test_간격_배수_높이만(tmp_path):
path = tmp_path / "contour.geojson"
features = [_line(775.0, 0), _line(780.0, 1), _line(785.0, 2), _line(None, 3)]
path.write_text(json.dumps({"type": "FeatureCollection", "features": features}), "utf-8")
xs = lambda lines: [line[0][0] for line in lines] # noqa: E731
assert xs(_metric_lines(path, "EPSG:4326")) == [0, 1, 2, 3]
assert xs(_metric_lines(path, "EPSG:4326", None, 5)) == [0, 1, 2, 3]
assert xs(_metric_lines(path, "EPSG:4326", None, 10)) == [1, 3]
assert xs(_metric_lines(path, "EPSG:4326", (-1, -1, 1.5, 2), 10)) == [1]
def _watershed(root: Path) -> dict:
return next(kind for kind in list_kinds(root) if kind["layout"] == "watershed")
def test_유역도_종류_간격(tmp_path):
root = tmp_path / "proj"
assert _watershed(root)["contour_interval_m"] == 5
assert all("contour_interval_m" not in k for k in list_kinds(root) if k["layout"] == "plan")
kind = _watershed(root)
update_kind(root, kind["id"], kind["name"], [], None, 10)
assert _watershed(root)["contour_interval_m"] == 10
update_kind(root, kind["id"], kind["name"], []) # 간격 안 보냄 = 지금 값
assert _watershed(root)["contour_interval_m"] == 10
with pytest.raises(ValueError):
update_kind(root, kind["id"], kind["name"], [], None, 1)
def test_지문_유역도만(tmp_path, monkeypatch):
monkeypatch.setattr(fp, "detail_basins_path", lambda stored: tmp_path / "basins.geojson")
root = tmp_path / "proj"
longitudinal = root / "B06_Section" / "longitudinal" / "longitudinal.json"
longitudinal.parent.mkdir(parents=True)
longitudinal.write_text(json.dumps({"stations": [{"chainage_m": 0}]}), encoding="utf-8")
context = SimpleNamespace(
vertices=[SimpleNamespace(x=0.0, y=0.0), SimpleNamespace(x=10.0, y=0.0)],
crs="EPSG:5186",
surface_params={},
stored_path="x",
)
items = [
SimpleNamespace(id="cover", kind="cover"),
SimpleNamespace(id="plan_route", kind="plan"),
SimpleNamespace(id="plan_watershed", kind="plan"),
]
sources = {"title": {}, "designs": {}, "context": context}
def prints() -> dict:
found = fp.compute_fingerprints(root, longitudinal, items, sources)
return {key: value["fingerprint"] for key, value in found.items()}
def changed(before: dict, after: dict) -> set:
return {key for key in before if before[key] != after[key]}
first = prints()
kind = _watershed(root)
update_kind(root, kind["id"], kind["name"], [], None, 5) # 기본 종류를 파일로 내림 · 같은 값
assert changed(first, prints()) == set()
update_kind(root, kind["id"], kind["name"], [], None, 10)
ten = prints()
assert changed(first, ten) == {"plan_watershed"}
update_kind(root, kind["id"], kind["name"], [], None, 5)
assert prints() == first