"""PLAN 349-0g sub7 — 노선 초안을 둔 채 횡단 보기(B06) → 묶음 고리 없음 · 누가토량 그대로. · B05 꼭짓점 한 번 끌기 = 한 번 · B06 그리기 여러 번(카드가 새 노선 상세를 종단도에 render) = 0 번 · 누가토량 · 횡단 면적 B05 와 같음 · B06 에서 계획고 조작 하나 = 한 번 · B05 로 돌아와도 안 돎 · 입력 쓰기 막음 0 짝: `helper_349_0g_draft_b06_loop.cjs`(실제 TS 를 Node 로 · 서버 창구만 가짜 · 검증_sub7 노선). """ from __future__ import annotations import csv import json import subprocess import sys import tempfile from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from B05_Profile.B05_Profile_Structures_Schema import structure_type_map # noqa: E402 from common_util.common_util_surface_sampler import dtm_grid_bytes # noqa: E402 from config.config_system_design import STANDARD_CROSS_SECTION # noqa: E402 pytestmark = pytest.mark.skipif( not (ROOT / "config" / "node_modules" / "typescript").is_dir(), reason="프론트엔드 의존성 미설치", ) PROJECT = ROOT / "storage/1/3/6d3b2812-6d5a-4168-a932-40e4ae303d5a" # 검증_sub7 ROUTE = PROJECT / "B05_Profile/route" SECTION = PROJECT / "B06_Section" GRID = PROJECT / "B04_PreProcess/models/dtm_classification_smooth.npz" ONES = {g: {"loose": 1.0, "compacted": 1.0} for g in ("soil", "ripping_rock", "blasting_rock")} def _csv(path: Path) -> list[list[float]]: with path.open(encoding="utf-8") as handle: return [[float(r["x"]), float(r["y"])] for r in csv.DictReader(handle)] def _json(path: Path): return json.loads(path.read_text(encoding="utf-8")) @pytest.fixture(scope="module") def r() -> dict: if not (GRID.is_file() and (SECTION / "longitudinal/longitudinal.json").is_file()): pytest.skip("검증_sub7 없음") curves = _json(ROUTE / "planned_route_curves.json") sections = sorted( (_json(p) for p in (SECTION / "cross_sections").glob("cross_*.json")), key=lambda s: s["chainage_m"], ) pipes = _json(PROJECT / "B04_PreProcess/drainage/edits/pipe_points.json")["points"] job = { "line": _csv(ROUTE / "planned_route.csv"), "nodes": _csv(ROUTE / "planned_route_nodes.csv"), "curves": [ {k: c[k] for k in ("start", "apex", "end", "radius_m")} for c in curves["curves"] ], "stationSnap": bool(curves.get("station_snap")), "minRadius": curves["min_radius_m"], "interval": 20.0, "types": [ {"type_id": t.type_id, "group": t.group, "placement": t.placement} for t in structure_type_map().values() ], "pipes": pipes, "standard": STANDARD_CROSS_SECTION, "conversion": ONES, "detail": { "longitudinal": _json(SECTION / "longitudinal/longitudinal.json"), "cross_sections": sections, }, } with tempfile.TemporaryDirectory() as folder: path = Path(folder) / "job.json" path.write_text(json.dumps(job), encoding="utf-8") grid = Path(folder) / "grid.bin" grid.write_bytes(dtm_grid_bytes(GRID)) proc = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HERE / "helper_349_0g_draft_b06_loop.cjs"), str(path), str(grid)], capture_output=True, text=True, encoding="utf-8", timeout=300, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) def test_b05_끌기_한_번(r): assert r["b05"]["runs"] == [["route"]], r["b05"]["runs"] def test_b06_그리기_돌지_않음_누가토량_같음(r): b = r["inB06"] assert b["drawnIsDraft"] assert b["runs"] == 0 assert b["final"] == r["b05"]["final"] assert b["cut"] == r["b05"]["cut"] def test_b06_조작_하나_한_번_돌아와도_안_돎(r): assert r["grade"]["runs"] == [["grade"]], r["grade"]["runs"] assert r["back"]["runs"] == 0 assert r["back"]["blocked"] == 0