- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로 - 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판) - import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/ - 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob - design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄) - 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
118 lines
4.6 KiB
Python
118 lines
4.6 KiB
Python
"""225-1 B06 관 정보 글 자리 · 관보호공 0.1 m 이동 · 관 길이 표시 반올림 · B08 집계 정수.
|
|
|
|
화면 TS 를 그 자리에서 돌린 값(`helper_225_1_pipe_round.cjs`) + 파이썬 집계(`M02_Table_Fill`).
|
|
짝(반올림) = TS `pipeLengthWhole`(`B06_Section_UI_Cross_Culvert_Const.ts`) ↔
|
|
파이썬 `pipe_lengths_from_designs` — 사사오입 · 0.5 올림.
|
|
"""
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from M02_MasterTemplete.M02_Table_Fill import pipe_lengths_from_designs # noqa: E402
|
|
|
|
HELPER = Path(__file__).parent / "helper_225_1_pipe_round.cjs"
|
|
VALUES = [0.5, 1.4, 1.5, 2.5, 7.4, 7.5, 7.6, 10.0]
|
|
|
|
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(HELPER), json.dumps(VALUES)],
|
|
cwd=str(ROOT),
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
)
|
|
assert done.returncode == 0, done.stderr
|
|
return json.loads(done.stdout)
|
|
|
|
|
|
def test_관_정보_글은_노폭_라벨_바로_위(out: dict) -> None:
|
|
"""노폭 · 노견 라벨(y 180) 위 줄 = 180 − 13 · 세월교 글이 또 있으면 한 줄 더 위 · 같은 x."""
|
|
pipe, ford = out["infos"]
|
|
assert (pipe["x"], pipe["y"], pipe["inSvg"]) == (200, 167, True)
|
|
assert pipe["text"] == "관매설 Φ600m/m, L=8 m (7.6)"
|
|
assert (ford["x"], ford["y"]) == (200, 154)
|
|
|
|
|
|
def test_노폭_라벨_없으면_옛_자리_또는_안_그림(out: dict) -> None:
|
|
"""B07 덧그림(라벨 없음) — 관 글은 안 그림 · 세월교 글은 옛 자리."""
|
|
assert out["bareInfos"] == [{"x": 10, "y": 20, "text": "세월교"}]
|
|
|
|
|
|
def test_관보호공은_0_1m_걸음_세월교_흙막이만_1m(out: dict) -> None:
|
|
assert out["steps"] == {
|
|
"pipeOutlet": True,
|
|
"pipeInlet": True,
|
|
"fordGuard": False,
|
|
"hiddenOwn": True,
|
|
}
|
|
|
|
|
|
def test_좌우_한_번은_d_를_지금_자리로_묶음(out: dict) -> None:
|
|
"""d 빈 칸 그대로 x 만 넣으면 옛 기본 d(경사길이 4 m)로 튐 — 배관 기준벽만 묶음."""
|
|
assert out["patches"] == [
|
|
{"key": "outlet", "x": 0.1, "d": 0.4},
|
|
{"key": "extra0", "x": 0.1},
|
|
]
|
|
|
|
|
|
def test_관_길이는_벽_자리에서_0_1m_로(out: dict) -> None:
|
|
"""유출 벽을 0.1 m 씩 밀면 관 길이도 0.1 m 씩 — 정수 올림 · 길이 맞춤 이동 없음."""
|
|
lengths = [case["lengthM"] for case in out["moved"]]
|
|
assert lengths == [7.9, 8.0, 8.1, 8.2]
|
|
for case in out["moved"]:
|
|
assert case["lengthM"] == round(case["cut"], 1)
|
|
|
|
|
|
def test_표시는_정수_괄호_소수_첫째(out: dict) -> None:
|
|
assert out["text"][VALUES.index(7.6)] == "8 m (7.6)"
|
|
assert out["text"][VALUES.index(7.4)] == "7 m (7.4)"
|
|
assert out["text"][VALUES.index(7.5)] == "8 m (7.5)"
|
|
|
|
|
|
def test_B08_집계_값은_사사오입_정수() -> None:
|
|
designs = [
|
|
{"chainage_m": 10, "design": {"pipe_length_m": 7.6}},
|
|
{"chainage_m": 20, "design": {"pipe_length_m": 7.5}},
|
|
{"chainage_m": 30, "design": {"pipe_length_m": 7.4}},
|
|
]
|
|
assert pipe_lengths_from_designs(designs) == {10.0: 8, 20.0: 8, 30.0: 7}
|
|
|
|
|
|
def test_반올림_짝_거울(out: dict) -> None:
|
|
"""TS `pipeLengthWhole` ↔ 파이썬 집계 — 같은 값마다 같은 정수(0.5 올림)."""
|
|
designs = [{"chainage_m": i, "design": {"pipe_length_m": v}} for i, v in enumerate(VALUES)]
|
|
py = pipe_lengths_from_designs(designs)
|
|
assert [py[float(i)] for i in range(len(VALUES))] == out["whole"]
|
|
assert out["whole"] == [1, 1, 2, 3, 7, 8, 8, 10]
|
|
ts = (ROOT / "B06_Section" / "logic" / "B06_Section_UI_Cross_Culvert_Const.ts").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
assert "Math.floor(lengthM + 0.5)" in ts and "M02_Table_Fill.pipe_lengths_from_designs" in ts
|
|
src = (ROOT / "M02_MasterTemplete" / "M02_Table_Fill.py").read_text(encoding="utf-8")
|
|
assert "int(length + 0.5)" in src and "pipeLengthWhole" in src
|
|
|
|
|
|
def test_카드_글과_좌측_패널이_같은_표시를_씀() -> None:
|
|
card = (ROOT / "B06_Section" / "B06_Section_UI_Cross_Culvert.ts").read_text(encoding="utf-8")
|
|
assert (
|
|
"L=${pipeLengthText(pipe.lengthM)}" in card and "appendPipeInfoText(layer, pipeInfo" in card
|
|
)
|
|
panel = (ROOT / "B05_Profile" / "B05_Profile_UI_Drainage_Facility.ts").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
assert '"횡단 설계 뒤 셈" : pipeLengthText(length)' in panel
|