Files
Aislo/resources/tester/test_472_2_cross_order.py
T
eomsangdonandClaude Opus 5.5 89e04280d0 fix(472-2 덧 횡단 차례): 횡단 파일 = 측점(누가거리) 차례로 읽음 — 이름 차례면 cross_01080.16m 이 cross_01080m 앞
- cross_files_in_order 한 벌(Engine_Sections) — B06 상세 GET(_read_section_detail) · B07 측점 파일(_cross_files) 둘 다 이것으로
- B07 측점 도면 장 나눔의 이름 차례 sorted 걷음
- 시험 test_472_2_cross_order(옛 코드 빨강 셋 → 초록)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:54:48 +09:00

65 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""472-2 덧 — 횡단 파일을 측점(누가거리) 차례로 읽는지.
이름 차례면 `cross_01080.16m` 이 `cross_01080m` 앞(「.」 < 「m」) → GET 상세의 측점 차례가
어긋나 화면 차례 짝(detailCross)이 갈리고, B07 측점 도면 장 나눔도 차례가 뒤집힘.
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from B06_Section.B06_Section_Router import _read_section_detail # noqa: E402
from B07_DesignDetail.B07_DesignDetail_Router_Support_Io import _cross_files # noqa: E402
CHAINAGES = [1060.0, 1080.0, 1080.16, 1100.0, 999.5]
NAMES = {
1060.0: "cross_01060m.json",
1080.0: "cross_01080m.json",
1080.16: "cross_01080.16m.json",
1100.0: "cross_01100m.json",
999.5: "cross_00999.50m.json",
}
def _stage(tmp_path: Path) -> Path:
stage = tmp_path / "B05_Profile"
(stage / "cross_sections").mkdir(parents=True)
(stage / "longitudinal").mkdir()
longitudinal = stage / "longitudinal" / "longitudinal.json"
longitudinal.write_text(
json.dumps({"stations": [{"chainage_m": m} for m in CHAINAGES]}), encoding="utf-8"
)
for chainage, name in NAMES.items():
(stage / "cross_sections" / name).write_text(
json.dumps({"chainage_m": chainage, "samples": []}), encoding="utf-8"
)
return longitudinal
def test_상세_GET_은_측점_차례(tmp_path: Path) -> None:
longitudinal = _stage(tmp_path)
detail = _read_section_detail(tmp_path, str(longitudinal.relative_to(tmp_path)))
got = [section["chainage_m"] for section in detail["cross_sections"]]
assert got == sorted(CHAINAGES)
def test_B07_측점_파일도_측점_차례(tmp_path: Path) -> None:
longitudinal = _stage(tmp_path)
files = _cross_files(longitudinal, json.loads(longitudinal.read_text(encoding="utf-8")))
assert [path.name for path in files] == [NAMES[m] for m in sorted(CHAINAGES)]
def test_B07_장_나눔도_측점_차례() -> None:
"""장 나눔 쪽이 이름으로 다시 줄 세우지 않음(`sorted(_cross_files(…))` = 이름 차례)."""
source = (ROOT / "B07_DesignDetail" / "B07_DesignDetail_Router_Support.py").read_text(
encoding="utf-8"
)
assert "sorted(_cross_files(" not in source