Files
Aislo/resources/tester/test_b06_pavement_and_ford.py
T
eomsangdonandClaude Opus 5.5 baa2438116 test(structure): 73-10 옛 기대값 정리 — 세월교 련 2 · 물넘이 경사각 3° · 내공 줄 숨김 · 관경 빈 배관 · 필수 칸 빈 보기
- test_b06_ford_set: 정의 기본 2련(65-4) · 소유 측점 붙기 = 관경 적은 배관으로(54-39 관경 빈 값 = 관 없음)
- test_b06_pavement_and_ford · test_b06_facility_default_notes: 경사각 빈 값 = 정의 기본 3° → % · 「경사각 3」 기본값 목록(65-5 · 66-2)
- test_b06_adjust_single_form: 집수정 내공 줄 화면 숨김(54-40)
- test_b06_detail_options: optionControl 셋째 인자(52-12) · 필수 · 기본값 칸 빈 보기 없음(54-43)
- 코드 그대로 · 대상 77 파일 394 통과 2 건너뜀

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVPp2o6Mh2FZJr72yW3ofZ
2026-10-07 08:30:41 +09:00

148 lines
5.7 KiB
Python

"""포장 구간 정본 + 물넘이포장 횡단 스펙 — 2026-08-28 사용자 확정 스펙.
- 포장은 **사용자가 구간으로 지정**한다(구조물 정본 G군). 종단경사 자동 판정은 더 이상
포장을 켜지 않고 경고(`pavement_suggested`)로만 남는다.
- 물넘이포장은 노면을 월류 폭만큼 판 자리다 — 범위 안 모든 횡단도에 붙고, 그 범위는
언제나 포장이다.
"""
import json
import math
from B06_Section.B06_Section_Engine_Culvert import (
FORD_PAVEMENT_DEFAULT_WIDTH_M,
attach_culvert_sets,
load_culvert_sets,
)
from B06_Section.B06_Section_Router_Design import paved_at, pavement_ranges
def _write_pipe_points(root, points):
edits = root / "B04_PreProcess" / "drainage" / "edits"
edits.mkdir(parents=True, exist_ok=True)
(edits / "pipe_points.json").write_text(
json.dumps({"route_signature": "무관", "points": points}, ensure_ascii=False),
encoding="utf-8",
)
def _write_structures(root, structures):
route_dir = root / "B05_Profile" / "route"
route_dir.mkdir(parents=True, exist_ok=True)
(route_dir / "structures.json").write_text(
json.dumps({"revision": 1, "structures": structures}, ensure_ascii=False),
encoding="utf-8",
)
FORD = {
"chainage_m": 100.0,
"source": "user",
"facility": "ford_pavement",
"options": {"ford_width_m": 6.0, "ford_height_m": 0.4, "ford_slope_pct": 3.0},
}
# ── 물넘이 스펙 ────────────────────────────────────────────────────────────
def test_ford_pavement_becomes_its_own_spec(tmp_path):
_write_pipe_points(tmp_path, [FORD])
(spec,) = load_culvert_sets(tmp_path).values()
assert spec["type"] == "ford_pavement"
assert spec["span_m"] == 6.0
assert spec["depth_m"] == 0.4
assert spec["slope_pct"] == 3.0
def test_ford_pavement_without_values_keeps_default_width_and_no_depth(tmp_path):
"""깊이는 지어내지 않는다 — 없으면 None이라 화면이 파임을 그리지 않는다.
경사는 빈 값이면 정의 기본 3° → %(65-5 · 66-2)."""
_write_pipe_points(tmp_path, [{"chainage_m": 50.0, "facility": "ford_pavement"}])
(spec,) = load_culvert_sets(tmp_path).values()
assert spec["span_m"] == FORD_PAVEMENT_DEFAULT_WIDTH_M
assert spec["depth_m"] is None
assert spec["slope_pct"] == round(math.tan(math.radians(3)) * 100.0, 4)
def test_ford_pavement_attaches_to_every_section_in_span(tmp_path):
"""월류 폭 6m → 기준측점 ±3m 안의 측점 전부에 붙는다(다른 시설은 소유 측점 한 곳)."""
_write_pipe_points(tmp_path, [FORD])
sections = [{"chainage_m": value} for value in (94.0, 97.5, 100.0, 102.5, 106.0)]
attach_culvert_sets(tmp_path, sections)
attached = [s["chainage_m"] for s in sections if "ford_pavement" in s]
assert attached == [97.5, 100.0, 102.5]
assert all("culvert" not in s and "ford" not in s for s in sections)
# ── 포장 구간 ──────────────────────────────────────────────────────────────
def test_pavement_range_comes_from_group_g_structure(tmp_path):
_write_structures(
tmp_path,
[
{
"type_id": "pavement_concrete",
"chainage_m": 200.0,
"start_m": 180.0,
"end_m": 230.0,
"placement": "interval",
}
],
)
assert pavement_ranges(tmp_path) == [(180.0, 230.0)]
def test_ford_pavement_range_is_always_paved(tmp_path):
_write_pipe_points(tmp_path, [FORD])
ranges = pavement_ranges(tmp_path)
assert ranges == [(97.0, 103.0)]
assert paved_at(100.0, ranges) is True
assert paved_at(97.0, ranges) is True
assert paved_at(96.9, ranges) is False
def test_other_groups_are_not_pavement(tmp_path):
_write_structures(
tmp_path,
[
{
"type_id": "revetment",
"chainage_m": 100.0,
"start_m": 100.0,
"end_m": 115.0,
"placement": "interval",
}
],
)
assert pavement_ranges(tmp_path) == []
def test_missing_truth_files_are_not_an_error(tmp_path):
assert pavement_ranges(tmp_path) == []
# ── 포장 판정 규칙 ─────────────────────────────────────────────────────────
def test_outside_range_keeps_user_value_and_defaults_unpaved():
"""경사 제안은 더 이상 포장을 켜지 않는다 — 구간 밖은 사용자 값(없으면 비포장)."""
ranges = [(10.0, 20.0)]
assert paved_at(30.0, ranges) is False
assert paved_at(30.0, ranges, True) is True
assert paved_at(30.0, ranges, False) is False
def test_inside_range_overrides_user_off_switch():
"""구간 안은 강제 포장 — 물넘이는 콘크리트 노면이고 지정 구간은 자동 반영이다."""
assert paved_at(15.0, [(10.0, 20.0)], False) is True
# ── 독립 기슭막이 ─────────────────────────────────────────────────────────
#
# 2026-08-28 이관으로 기슭막이는 구조물 정본 D군을 떠나 관 지점 시설이 됐다. 전용 엔진
# (`B06_Section_Engine_Revetment`)은 호출자가 사라져 2026-09-01 삭제했다 — 벽은 관 세트
# (`B06_Section_Engine_Culvert._revet_set`)가 만든다. 그쪽 검증은
# `test_revet_span_source.py`에 있다.