# -*- coding: utf-8 -*- """346-2 4파 — 측점 수가 바뀔 때 횡단 목록 갈아끼움. 못박는 것 - 측점 셋 늘고 둘 빠진 목록 → 새 상세 객체(카드 8 · 종단 측점 8) · 이어 받은 측점은 설계 그대로 · 새 측점은 지반 표본 + 기본 설계 · 옛 상세는 그대로 · 같은 목록이면 안 갈아끼움. - 가게 `stations` → 캐시 상세 갈아끼움 · 듣는 쪽에 새 상세 + 누가거리 옮김 · 카드 선택은 측점 열쇠로 새 자리(관 45.054 → 47 m) · 노선 모양이 바뀌면 넘김 규칙 (단면 유형 버림) · 사라진 측점 고침 버림 · 조정창 값도 옮긴 자리로. - 종단 보기(B05) · 3D 측점선 — 횡단 보기를 안 열어도 가게 측점으로 갈아끼움 · 보일 때만 다시 그림. - 보이는 카드 먼저 — 보이는 줄 + 한 줄만 바로. - `formatStation` ↔ 파이썬 `format_station` 같은 글. Node 헬퍼 `helper_346_2_station_swap.mjs` 가 vite ssr 로 묶은 진짜 모듈 (`helper_346_2_swap_entry.ts`)을 부름. """ import json import shutil import subprocess import sys 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_Engine_Sections_Core import format_station # noqa: E402 @pytest.fixture(scope="module") def out(tmp_path_factory): work = tmp_path_factory.mktemp("b346") build = subprocess.run( [ "node", str(ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"), "build", "--configLoader", "runner", "--ssr", "../resources/tester/helper_346_2_swap_entry.ts", "--outDir", str(work), "--logLevel", "error", ], cwd=ROOT, capture_output=True, text=True, encoding="utf-8", timeout=300, ) assert build.returncode == 0, build.stderr bundle = work / "bundle.mjs" shutil.copy(work / "helper_346_2_swap_entry.js", bundle) proc = subprocess.run( ["node", str(HERE / "helper_346_2_station_swap.mjs"), str(bundle)], cwd=ROOT, capture_output=True, text=True, encoding="utf-8", timeout=120, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) def test_셋_늘고_둘_빠진_목록으로_갈아끼움(out): pure = out["pure"] assert pure["count"] == 8 and pure["longCount"] == 8 assert pure["added"] == ["structure:st-1", "structure:st-2", "structure:st-3"] assert pure["removed"] == ["grid:2", "grid:4"] assert pure["moves"] == {"45.05": "47.00", "100.00": "90.00"} assert pure["keptMark"] == [ "old-0", "old-20", "old-45.054", None, "old-60", None, None, "old-100", ] assert pure["kinds"] == [ "bp", "regular", "irregular", "irregular", "regular", "irregular", "irregular", "ep", ] assert pure["labels"] == ["STA.0+047.000", "STA.0+090.000"] assert pure["samples"] == [-0.5, 0, 0.5] assert pure["oldUntouched"] is True and pure["length"] == 90 assert pure["same"] is False and pure["sameSelf"] is True def test_측점_글_파이썬과_같음(out): assert out["format"] == [format_station(c) for c in (0, 45.054, 1234.5)] def test_가게_측점으로_상세_갈아끼움_열쇠로_이어_받기(out): store = out["store"] assert store["replaced"] is True and store["count"] == 8 assert store["heard"] == [{"count": 8, "moves": {"45.05": "47.00", "100.00": "90.00"}}] # 관 고침은 47 m 로 · 노선 모양이 바뀌어 단면 유형은 버림 · 40 m(grid:2) 고침은 노선 밖 assert store["choices"] == [[20, "soil", None], [47, "blasting_rock", None]] assert store["rawKeys"] == ["grid:1", "pipe:pipe-s1"] assert store["widths"] == {"47.00": 12, "47.00:outlet": 3, "20.00": 8} assert store["redraws"] == 1 # 보이는 횡단 보기 = 카드 · 그림 한 번 다시 assert store["again"] is True # 같은 목록 = 안 갈아끼움 def test_종단_보기_3D_측점선도_새_목록_보일_때만(out): profile = out["profile"] assert profile["afterShown"] == [7, 8] # 처음 7 → 가게 측점으로 갈아끼움 8(횡단 보기 없이) assert profile["whileHidden"] == [7, 8] # 숨은 동안은 안 그림 assert profile["afterShow"] == [7, 8, 6] # 다시 보일 때 새 목록(6) assert profile["lines"] == 3 # 3D 측점선도 같은 차례로 다시 def test_보이는_카드_먼저(out): assert out["eager"] == [12, 27, 4] # 3열 · 600 px · (250+12) px 줄 = 3 줄 + 1 assert out["rename"] == {"47.00": 1, "b47.00": 2, "47.00:outlet": 3, "60.00": 4}