"""457 노선 바뀜 — 초안 카드 그림 · 이름 · 횡단 맥락 = 지금 현황을 새 측점에 다시 얹음(요구 270). 재현 E · F(시점 당김 +13 · +7 — 배관 · 물넘이포장 · 옹벽) · G(세션에서 놓은 BOX) · H(관 둘 엇갈려 옮김 · 초안 둔 채 열기). ① 모든 측점 카드 그림 · 이름 = 새 측점에 따라간 관 · 구조물을 얹은 것(캐시 `withDraftShapes` 한 벌) ② 시설마다 제 측점 하나 · 옛 측점 그림을 옮기지 않음 · 카드 번호만 열쇠로 이어 받음 ③ 시설 맥락(포장 · 기울임 · 하강) = 다시 얹은 그림에서 · 짝 = 등록 열쇠(차례 짝 없음 · 엇갈림 0) ④ 가게 쓰기 = 지금 가게 값과 견줌(되돌리기 뒤 같은 조작도 씀) TS 셈은 `helper_457_draft_card.cjs`. ./venv/Scripts/python.exe -m pytest resources/tester/test_457_draft_card.py -q """ import json import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[2] HELPER = Path(__file__).with_name("helper_457_draft_card.cjs") pytestmark = pytest.mark.skipif( not (ROOT / "config" / "node_modules" / "typescript").is_dir(), reason="프론트엔드 의존성 미설치", ) @pytest.fixture(scope="module") def got() -> dict: run = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HELPER)], capture_output=True, text=True, encoding="utf-8", timeout=120, ) assert run.returncode == 0, run.stderr return json.loads(run.stdout) def _row(rows: list, key: str) -> dict: return next(r for r in rows if r["key"] == key) @pytest.mark.parametrize("name", ["E", "F", "G", "H"]) def test_카드_그림_이름이_새_자리_현황(got, name) -> None: rows = got[name]["rows"] bad = [(r["key"], r["card"], r["truth"]) for r in rows if r["card"] != r["truth"]] assert not bad names = [(r["key"], r["name"], r["truthName"]) for r in rows if r["name"] != r["truthName"]] assert not names @pytest.mark.parametrize("name", ["E", "F", "G", "H"]) def test_카드_번호만_이어_받음(got, name) -> None: assert got[name]["specFields"] == ["station_id"] def test_E_물넘이포장은_제_측점에만(got) -> None: rows = got["E"]["rows"] fp = _row(rows, "pipe:fp") assert "ford_pavement@" in fp["card"] assert fp["ctx"][:2] == [True, True] # 포장 · 기울임 = 새 자리 그림 no6 = _row(rows, "grid:6") # 120 m — 옛 물넘이 범위(119~131) · 새 범위(132~144) 밖 assert "ford_pavement" not in no6["card"] and no6["name"] is None assert no6["ctx"] == [False, False, None, 0] pipes = [r for r in rows if "culvert@" in r["card"]] assert [r["key"] for r in pipes] == ["pipe:p1"] # 배관 그림 = 관 측점 하나(No.3 아님) def test_G_세션에서_놓은_BOX_카드(got) -> None: box = _row(got["G"]["rows"], "pipe:p9") assert "box@" in box["card"] and box["name"] def test_H_엇갈려_옮긴_관_짝(got) -> None: h = got["H"] p1 = _row(h["rows"], "pipe:p1") p2 = _row(h["rows"], "pipe:p2") assert "culvert@" in p1["card"] and "box@" not in p1["card"] assert "box@" in p2["card"] and "culvert@" not in p2["card"] # 카드 번호 = 같은 관의 화면 상세 번호(등록 열쇠 짝 · 목록이 바뀌어도 처음 본 열쇠) assert h["sourceKeys"]["pipe:p1"] == h["canonIds"]["pipe:p1"] assert h["sourceKeys"]["pipe:p2"] == h["canonIds"]["pipe:p2"] assert p1["id"] == h["canonIds"]["pipe:p1"] def test_가게_쓰기는_지금_가게_값과_견줌() -> None: page = (ROOT / "A00_Common" / "design" / "design_pipeline_page.ts").read_text(encoding="utf-8") body = page[page.index("function writeFacilities") :] body = body[: body.index("\n }\n")] assert 'same(store.get("pipes"), next.pipes)' in body assert 'same(store.get("structures"), next.structures)' in body assert "written" not in page