"""421-2 추천 창 — 「못 지킨 구간」 = R · 계류 · 측점만 · 원지반 기울기(참고) 줄 · 시종점 알림. ./venv/Scripts/python.exe -m pytest resources/tester/test_421_2_violation_lines.py -q """ import json import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[2] B05 = ROOT / "B05_Profile" HELPER = Path(__file__).with_name("helper_421_2_violation_lines.cjs") def _lines() -> dict: run = subprocess.run( ["node", str(HELPER)], capture_output=True, text=True, encoding="utf-8", check=True ) return json.loads(run.stdout) def test_못_지킨_구간은_기울기_빼고_기준_초과와_같음() -> None: now = _lines()["now"] assert now["violations"].startswith("제약 못 지킨 구간 2곳: No.3 R 10.0m") assert "28.8%" not in now["violations"] and "No.5+3.0 측점 밖 3.0m" in now["violations"] assert now["over"] == 2 and "기준 초과 2구간" in now["route"] # 서버 total 4 아님 assert now["ground"] == "원지반 기울기(참고) 최대 35.8% · 상한 넘는 곳 2" assert now["groundTitle"].split("\n") == [ "No.1 28.8%(원지반 기울기)", "No.4 18.9%(원지반 기울기)", ] assert now["ends"] == ( "시종점 높이 차가 상한을 넘음(평균 16.2%) — 종단으로 못 맞춤 · 노선을 늘려야 함" ) def test_기울기만_넘으면_모두_지킴_시종점_알림_없음() -> None: clean = _lines()["clean"] assert clean["violations"] == "제약 못 지킨 구간 없음 — 모두 지킴" assert clean["over"] == 0 and clean["ground"].endswith("상한 넘는 곳 1") assert clean["ends"] == "" def test_옛_답은_서버_수_그대로_줄_없음() -> None: old = _lines()["old"] assert ( old["over"] == 3 and old["violations"] == "" and old["ground"] == "" and old["ends"] == "" ) def test_창에_줄_두_개와_도움말() -> None: rec = (B05 / "B05_Profile_UI_RouteEdit_Recommend.ts").read_text(encoding="utf-8") assert '' in rec assert '' in rec assert 'line("violations").title = (brokenItems(view?.metrics ?? null) ?? [])' in rec assert "const ends = endsLine(view);" in rec help_ts = (B05 / "B05_Profile_UI_RouteEdit_Recommend_Help.ts").read_text(encoding="utf-8") for name in ('name: "원지반 기울기(참고)",', 'name: "시종점 높이 차",'): assert name in help_ts assert "이보다 가파른 구간을 만들지 않음" not in help_ts assert "「기준 초과」 수와 같음" in help_ts