# -*- coding: utf-8 -*- """346-2 덧 3 — 노선 초안 동안 횡단 카드 · 종단 구조물 알약. 못박는 것 - 횡단 카드 = 노선 초안 동안 묶음 새 노선 상세(`pipelineDetail`) · profile · cross 단계 뒤 다시 그림 · 숨은 동안은 안 그림(상세는 새것) · 초안을 버리면 저장 노선 카드 · 묶음이 횡단 보기보다 늦게 서도 붙음 · 끊으면 안 그림. - 종단 알약 = follow 뒤 자리 — 구조물은 id 짝 · 관은 세션 id ≠ 서버 id 라 누가거리 차례 짝 · 구간형 띠도 옮김 · 짝 없는 것은 그대로 · 관 수가 안 맞으면 관은 안 옮김 · 초안을 버리면 저장 자리. Node 헬퍼 `helper_346_2_draft_cross_pills.cjs` 가 진짜 TS 를 트랜스파일해 부름. """ import json import subprocess from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] @pytest.fixture(scope="module") def out(): proc = subprocess.run( ["node", str(HERE / "helper_346_2_draft_cross_pills.cjs")], 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): cards = out["cards"] assert cards["before"] == "saved" assert cards["afterDraft"] == ["draft-profile-1", "draft-cross-1"] assert cards["draftNow"] == "draft-cross-1" def test_숨은_동안은_안_그림(out): cards = out["cards"] assert cards["whileHidden"] == ["draft-profile-1", "draft-cross-1"] assert cards["hiddenNow"] == "draft-cross-2" def test_초안_버리면_저장_노선_카드(out): cards = out["cards"] assert cards["discarded"][-1] == "saved" and cards["savedNow"] == "saved" assert cards["afterStop"] == 3 # 끊은 뒤엔 안 그림 def test_알약은_따라간_누가거리(out): draft = out["pills"]["draft"] # x = 누가거리 × 10 px — 관 30 → 33 · 90 → 96(차례 짝) · 구조물 id 짝 · 짝 없는 st-9 그대로 assert draft["left"] == { "pipe-s1": 330, "st-1": 550, "st-2": 720, "pipe-s2": 960, "st-9": 1200, } assert draft["band"] == [620, 200] # 구간형 띠 62 ~ 82 m def test_초안_버리면_저장_자리_관_수_다르면_관은_그대로(out): pills = out["pills"] assert pills["saved"]["left"] == { "pipe-s1": 300, "st-1": 500, "st-2": 700, "pipe-s2": 900, "st-9": 1200, } assert pills["saved"]["band"] == [600, 200] assert pills["short"] == [30, 55, 72, 90, 120] assert pills["untouched"] == 50 # 원본 목록은 안 고침