Files
Aislo/resources/tester/test_281_1_drainage_zoom_range.py
T

92 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""281 B05 · B06 아래 종단 패널 배수유역 지도 — 줌아웃 한계 = 노선 기준.
- 한계 = 노선 범위 2 배가 화면에 드는 배율 · 유역이 밖이면 유역까지 · 도엽 전체(배율 1)보다 멀리 안 감
- 노선이 없으면 종전 0.5 · 처음 보기(노선 + 여유)보다 좁히지 않음
- 휠은 한계 · 상한에서 멈춤 · 이미 한계 밖이면 더 안 빠지고 튀지도 않음
Node 헬퍼(`helper_281_1_drainage_zoom_range.cjs`)가 TS 를 그 자리에서 돌린다.
도엽 4000 × 3000 m · 화면 800 × 600 — 배율 1 = 화면 폭 4000 m.
"""
import json
import os
import subprocess
from pathlib import Path
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = Path(HERE).parents[1]
@pytest.fixture(scope="module")
def r():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_281_1_drainage_zoom_range.cjs")],
capture_output=True,
text=True,
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_상수는_한_곳(r):
assert r["factor"] == 2
assert r["fallbackConst"] == 0.5
def test_노선만_2배가_화면에(r):
"""노선 1000 × 500 m → 2 배 2000 × 1000 m · 폭이 이김 → 화면 폭 2000 m(배율 2)."""
assert r["routeOnly"] == pytest.approx(2.0)
assert r["routeOnlyViewM"] == pytest.approx(2000)
def test_유역이_밖이면_유역까지(r):
"""유역 서쪽 끝 400 m → 범위 400 ~ 3000 m = 폭 2600 m."""
assert r["basinOutViewM"] == pytest.approx(2600)
def test_유역이_안이면_그대로(r):
assert r["basinIn"] == pytest.approx(r["routeOnly"])
def test_노선_없음은_종전(r):
assert r["noRoute"] == 0.5
assert r["noMeta"] == 0.5
def test_도엽보다_큰_범위는_도엽_전체에서_멈춤(r):
assert r["wide"] == pytest.approx(1.0)
def test_짧은_노선은_처음_보기보다_좁히지_않음(r):
assert r["short"] == pytest.approx(r["shortInitial"])
def test_휠이_한계_안에서_멈춤(r):
assert r["wheelOutStop"] == pytest.approx(r["routeOnly"])
assert r["wheelInStop"] == pytest.approx(200)
assert r["outside"] == pytest.approx(1.2)
def _read(rel: str) -> str:
return (ROOT / rel).read_text(encoding="utf-8")
def test_휠과_창_크기가_한계를_씀():
interact = _read("B05_Profile/B05_Profile_UI_Drainage_Interact.ts")
assert "Math.max(0.5" not in interact
assert "params.getMinScale()" in interact
panel = _read("B05_Profile/B05_Profile_UI_Drainage_Panel.ts")
assert "getMinScale: zoomOutLimit" in panel
assert "scale < zoomOutLimit() * 0.999) fitToRoute()" in panel
assert len(panel.splitlines()) <= 700
def test_B04_공용은_그대로():
"""B04 지도 · 노선 편집 지도는 0.5 하한을 그대로 씀(공용 함수 안 바꿈)."""
render = _read("B04_PreProcess/B04_PreProcess_UI_MapRender.ts")
assert "ZoomRange" not in render