72 lines
3.4 KiB
Python
72 lines
3.4 KiB
Python
"""저장된 표준 횡단면이 **브라우저까지 닿는지**.
|
|
|
|
왜 (2026-09-07 실측) — 표준단면 편집값은 sessionStorage 에만 살아서 **탭을 새로 열면**
|
|
사라졌다. 그때 브라우저는 config 기본값으로, 서버는 저장분으로 계산해 같은 측점이 갈렸다.
|
|
용화(route 169) 실측 — 저장분은 암반 횡단경사 **5%** · 측구 상단폭 **0.9m**,
|
|
config 기본값은 **3%** · **0.69m**. 표준단면은 모든 측점의 횡단 모양을 정하므로
|
|
면적·유토곡선·수량까지 그대로 흐른다.
|
|
|
|
고침은 두 줄이다 — `sections/context` 가 저장분을 **한 칸 더** 실어 보내고(기존 기본값 칸은
|
|
그대로), 브라우저가 **세션이 비었을 때만** 그 값으로 셈(초안 칸에 베끼지 않음 · 472 덧).
|
|
이 시험은 그 두 성질을 지킨다.
|
|
"""
|
|
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from B06_Section.B06_Section_Schema import SectionContextResponse # noqa: E402
|
|
|
|
_FETCH = PROJECT_ROOT / "B06_Section" / "B06_Section_Api_Context.ts" # 472-2 세션 창구 갈라냄
|
|
_ROUTER = PROJECT_ROOT / "B06_Section" / "B06_Section_Router.py"
|
|
|
|
|
|
def test_응답에_저장분_칸이_따로_있다():
|
|
"""기존 기본값 칸은 그대로 두고 한 칸만 더한 것 — 옛 화면이 안 깨진다."""
|
|
fields = SectionContextResponse.model_fields
|
|
assert "standard_cross_section" in fields, "기본값 칸이 사라짐"
|
|
assert "stored_standard_cross_section" in fields, "저장분 칸이 없음"
|
|
# 저장분이 없는 프로젝트도 있다 — 그때는 None 이어야 기본값으로 선다.
|
|
empty = SectionContextResponse(project_id="x", defaults=_defaults())
|
|
assert empty.stored_standard_cross_section is None
|
|
|
|
|
|
def _defaults():
|
|
from B06_Section.B06_Section_Schema import SectionOptionDefaults
|
|
|
|
return SectionOptionDefaults(
|
|
station_interval_m=20.0,
|
|
cross_half_width_m=20.0,
|
|
cross_sample_interval_m=0.5,
|
|
long_sample_interval_m=1.0,
|
|
vertical_exaggeration=2.0,
|
|
)
|
|
|
|
|
|
def test_라우터가_저장분을_실어_보낸다():
|
|
source = _ROUTER.read_text(encoding="utf-8")
|
|
assert "stored_standard_cross_section=stored_standard" in source, "응답에 안 실림"
|
|
assert "_stored_standard_cross_section(longitudinal_row)" in source, "저장분을 안 읽음"
|
|
|
|
|
|
def test_브라우저는_세션이_빈_경우에만_저장분으로_선다():
|
|
"""사용자가 그 탭에서 고친 값이 있으면 그 값 — 없으면 저장분(472 덧 · 요구 272 C).
|
|
|
|
옛 판은 세션이 비면 저장분을 초안 칸(`std-cross`)에 베꼈음 → 열기만 해도 초안이 섬.
|
|
지금은 설정값 칸(`section-context`)에서 바로 읽음 — 세션 고침 → 저장분 → config 차례.
|
|
"""
|
|
source = _FETCH.read_text(encoding="utf-8")
|
|
assert '"std-cross"' not in source, "설정값 받기가 초안 칸에 씀"
|
|
panel = (_FETCH.parent / "B06_Section_UI_Standard_Panel.ts").read_text(encoding="utf-8")
|
|
assert "stored_standard_cross_section" in panel, "저장분을 안 읽음"
|
|
order = re.search(
|
|
r"readStandardCrossSession\(projectId\) \?\?\s*readStoredStandard\(projectId\) \?\?\s*"
|
|
r"readStandardDefaults\(projectId\)",
|
|
panel,
|
|
)
|
|
assert order, "세션 → 저장분 → config 차례가 아님"
|