"""136-1 폼 → 캐시 chute — 좌측 패널 도수로/돌붙임 상자가 [저장] 전에 횡단 제원에 바로 얹힘. 관 · BOX(폭 걸친 측점 둘) · 세월교 · 물넘이 포장(`ford_chute_*`) · 지움 · 일부만 온 되얹기. 화면 TS 를 그 자리에서 돌린 값(`helper_136_chute_form_cache.cjs`). """ import json import subprocess from pathlib import Path import pytest HERE = Path(__file__).parent ROOT = HERE.parents[1] pytestmark = pytest.mark.skipif( not (ROOT / "config" / "node_modules").is_dir(), reason="프론트엔드 의존성 미설치" ) @pytest.fixture(scope="module") def out() -> dict: done = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HERE / "helper_136_chute_form_cache.cjs")], capture_output=True, text=True, encoding="utf-8", ) assert done.returncode == 0, done.stderr return json.loads(done.stdout) def test_관_상자_넣으면_바로_chute_와_카드(out: dict) -> None: assert out["pipeAdd"]["pipe"] == {"structure": "돌붙임", "thickness_m": 0.4} assert 85 in out["pipeAdd"]["refreshed"] # 같은 값이면 chute 때문에 다시 그리진 않음(관 길의 카드 갱신만) assert out["pipeSame"]["pipe"] == out["pipeAdd"]["pipe"] def test_되얹기는_상자_없으면_그대로_칸_전부면_지움(out: dict) -> None: assert out["replayNoChute"]["pipe"] == {"structure": "돌붙임", "thickness_m": 0.4} assert out["pipeRemove"]["pipe"] is None def test_박스는_걸친_측점_모두_세월교도(out: dict) -> None: assert out["boxAdd"]["box"] == [{"structure": "도수로", "thickness_m": 0.3}] * 2 assert {118, 120} <= set(out["boxAdd"]["refreshed"]) assert out["fordAdd"]["ford"] == {"structure": "돌붙임", "thickness_m": 0.5} assert out["fordAdd"]["refreshed"] == [160] # 다른 관 지점은 안 건드림 assert out["fordAdd"]["pipe"] is None and out["fordAdd"]["box"][0] is not None def test_물넘이_포장은_ford_chute_만(out: dict) -> None: assert out["paveAdd"]["pave"] == [{"structure": "돌붙임", "thickness_m": 0.3}] * 2 assert out["paveAdd"]["refreshed"] == [196, 200]