Files
Aislo/resources/tester/test_346_2_station_swap.py
T
eomsangdonandClaude Opus 5.5 20f2044afe feat(횡단목록): 346-2 덧 측점 수가 바뀔 때 횡단 목록 갈아끼움 — 묶음 측점 → 새 상세 · 열쇠로 이어 받기 · 보이는 카드 먼저
- logic/B06_Section_Station_Swap: 묶음 측점(PipelineStation[]) → 새 상세 객체 · 같은 측점(열쇠 · 없으면 같은 자리 같은 종류)은 앞 횡단 이어 받음(설계 · 구조물 제원 · 이름) · 자리 · 지반 표본만 새것 · 새 측점 = 지반 표본 + 기본 설계 · 빠진 측점 뺌 · formatStation(파이썬 format_station 짝)
- Section_Store swapSectionStations: 같은 목록이면 그대로 · 바뀌면 캐시 · 세션 상세 갈아끼움 · 옛 열쇠 = 세워 둔 목록(옮긴 관도 옛 id) · 새 열쇠 = 묶음이 정한 것 · 노선 모양이 바뀐 차례면 세션 고침 넘김(사라진 측점 = 「노선 밖 고침 N 건」) · 듣는 쪽 subscribeSectionDetail
- 횡단 보기 followSwaps(가게 stations 따라감): 조정창 값(반폭 · 기슭막이 · 유입 · 집수정 · 추가 벽)을 옮긴 자리로 · 암 경계 · 암 경사 다시 읽음 · 보일 때 카드 · 종단도 다시 · 떠난 보기의 옛 맵은 지금 값을 안 덮음
- 카드 통째 그리기 = 보이는 줄 + 한 줄만 바로 · 나머지는 같은 id 빈 자리 → 쉬는 틈에 진짜 카드
- 시험: 셋 늘고 둘 빠진 목록(카드 8) · 관 45.054 → 47 m 고침 이어 받음 · 노선 밖 고침 버림 · 조정창 옮김 · 같은 목록 안 갈아끼움 · 보이는 카드 수

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfHKQs7J3hQELKMWQMUJEy
2026-10-16 12:14:54 +09:00

122 lines
4.3 KiB
Python

# -*- coding: utf-8 -*-
"""346-2 4파 — 측점 수가 바뀔 때 횡단 목록 갈아끼움.
못박는 것
- 측점 셋 늘고 둘 빠진 목록 → 새 상세 객체(카드 8 · 종단 측점 8) · 이어 받은 측점은 설계 그대로 ·
새 측점은 지반 표본 + 기본 설계 · 옛 상세는 그대로 · 같은 목록이면 안 갈아끼움.
- 가게 `stations` → 캐시 상세 갈아끼움 · 듣는 쪽에 새 상세 + 누가거리 옮김 ·
카드 선택은 측점 열쇠로 새 자리(관 45.054 → 47 m) · 노선 모양이 바뀌면 넘김 규칙
(단면 유형 버림) · 사라진 측점 고침 버림 · 조정창 값도 옮긴 자리로.
- 보이는 카드 먼저 — 보이는 줄 + 한 줄만 바로.
- `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_보이는_카드_먼저(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}