Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015sDZSjFvoiDjdGpgj3muc3
45 lines
2.0 KiB
Python
45 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""PLAN 267-1 — B06 횡단 카드 「관매설 …」 글 크기 = 「노폭 …」 글 크기 · 줄 겹침 없음.
|
|
|
|
./venv/Scripts/python.exe -m pytest resources/tester/test_267_1_pipe_info_font.py -q -p no:cacheprovider --basetemp=tmp/pt
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
CSS = (ROOT / "B06_Section" / "B06_Section_UI_Style_Cross_Areas.css").read_text(encoding="utf-8")
|
|
TYPES = (ROOT / "B06_Section" / "B06_Section_UI_Cross_Culvert_Types.ts").read_text(encoding="utf-8")
|
|
|
|
|
|
def _font_px(selector: str) -> float:
|
|
"""셀렉터 블록의 마지막 font-size(px) — 뒤에 오는 규칙이 이긴다."""
|
|
blocks = re.findall(re.escape(selector) + r"\s*\{([^}]*)\}", CSS)
|
|
sizes = [float(m) for b in blocks for m in re.findall(r"font-size:\s*([\d.]+)px", b)]
|
|
assert sizes, selector
|
|
return sizes[-1]
|
|
|
|
|
|
def test_관_정보_글_크기가_노폭_라벨과_같다() -> None:
|
|
road = _font_px(".b06-chart__carriageway-label")
|
|
info = _font_px(".b06-chart__culvert-label.b06-chart__pipe-info")
|
|
assert road == info == 11.0
|
|
# 다른 culvert-label(집수정 · 박스 이름)은 그대로 9px
|
|
assert _font_px(".b06-chart__culvert-label") == 9.0
|
|
|
|
|
|
def test_관_정보_글_줄이_노폭_라벨과_겹치지_않는다() -> None:
|
|
step = float(re.search(r"- (\d+) \* \(stacked \+ 1\)", TYPES).group(1))
|
|
font = _font_px(".b06-chart__culvert-label.b06-chart__pipe-info")
|
|
road_font = _font_px(".b06-chart__carriageway-label")
|
|
asc, desc = 0.8, 0.2 # 글자 상자 근사 — 기준선 위 80% · 아래 20%
|
|
road_top = 0 - asc * road_font # 노폭 라벨 기준선 y=0
|
|
for n in (1, 2, 3): # 관 정보 글이 쌓인 줄 수
|
|
info_y = -step * n
|
|
info_bottom = info_y + desc * font
|
|
assert info_bottom < road_top, (n, info_bottom, road_top)
|
|
if n > 1: # 윗줄 바닥 < 아랫줄 윗면
|
|
upper_bottom = -step * n + desc * font
|
|
lower_top = -step * (n - 1) - asc * font
|
|
assert upper_bottom < lower_top, n
|