Files
Aislo/resources/tester/test_b06_ground_unlock.py
T
eomsangdonandClaude Opus 5.5 e4befd158a refactor(472-3 B06 구조물): 관 · BOX · 세월교 · 물넘이 모양 계산을 logic 으로 옮김(518-2)
- logic 새 파일 9 — B06_Section_Cross_Culvert · _Culvert_Geom · _Culvert_Extra · _Culvert_Tiers ·
  _Culvert_Types · _Culvert_Wire · _Box_Geom · _Ford_Geom · _Ford_Pavement
- 그림 파일(UI_Cross_Culvert · _Culvert_Types · _Box · _Ford · _Ford_Pavement)은 받은 좌표로 그리기만 ·
  관 겹 꼭짓점(pipeShellCorners) · 물넘이 노면 끝 · 월류선 · 유출 성토선은 logic 으로
- 옛 순수 기하 6 파일(UI_Cross_Culvert_Geom · _Extra · _Tiers · _Wire · _Box_Geom · _Ford_Geom) 지움 ·
  부르는 쪽(B05 Corridor · Structure_Layouts · Route_Carry_Patch · Wall 등)은 import 줄만
- test_472_3 GEOMETRY_PULLS 자기 11 줄 + 더는 안 끌리는 Design_Surface 1 줄 걷음
- 시험 · helper 경로를 새 logic 파일로 — 옮긴 파일을 가리키던 낡은 경로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 19:17:23 +09:00

109 lines
4.6 KiB
Python

"""원지반 잠금 풀기(54-45) — 흙막이 자리 · 다단 · 높이를 원지반이 막지 않음.
남는 규칙: 벽 윗면 노면 위 금지(d ≥ 0) · 관 보호공 흙막이 m 단위 자리(관 길이 정수).
서버 면적은 같은 TS 를 Node 로 돌림(`design_calc_node.ts` `structure.layouts`) — 번들도 같은 판인지 봄.
"""
import json
import re
import subprocess
from pathlib import Path
import pytest
PROJECT_ROOT = Path(__file__).resolve().parents[2]
B06 = PROJECT_ROOT / "B06_Section"
TSC = PROJECT_ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc"
BUNDLE = PROJECT_ROOT / "config" / "design_calc_node" / "design_calc_node.js"
_RUNNER = """
import { writeFileSync } from "node:fs";
import { placePipeWall } from "./B06_Section_UI_Cross_Culvert_Solve.js";
import { buildOutletExtras } from "./B06_Section_Cross_Culvert_Extra.js";
const pipe = (d, x) => placePipeWall({
autoOffset: 10, outward: 1, height: 2, baseElevation0: 98, edgeElevation: 100,
invertCap: Number.POSITIVE_INFINITY, adjust: { x, d, h: null, m: null }, defaultD: 4.8,
});
const extras = (ground, d) => buildOutletExtras({
start: { offset: 10, elevation: 95 }, startBottomElevation: 94.5, outward: 1,
groundAt: () => ground, limitOffset: 40,
adjusts: [{ x: 0, d, h: 2, m: null }, { x: 0, d, h: 2, m: null }],
});
const buried = extras(100, 1);
const high = extras(80, 3);
writeFileSync(process.argv[2], JSON.stringify({
deep: pipe(6, 2), up: pipe(-5, 0),
buriedCount: buried.walls.length, buriedD: buried.appliedAdjusts.map((a) => a.d),
highCount: high.walls.length, highD: high.appliedAdjusts.map((a) => a.d),
}));
"""
@pytest.mark.skipif(not TSC.is_file(), reason="프론트엔드 의존성 미설치")
def test_원지반이_자리_다단을_막지_않고_노면_위만_막음(tmp_path: Path) -> None:
out = tmp_path / "js"
for name in (
"logic/B06_Section_UI_Cross_Culvert_Solve",
"logic/B06_Section_Cross_Culvert_Extra",
):
subprocess.run( # noqa: S603 — 고정 실행 파일
[
"node",
str(TSC),
str(B06 / f"{name}.ts"),
"--outDir",
str(out),
"--module",
"esnext",
"--target",
"es2022",
"--moduleResolution",
"bundler",
"--skipLibCheck",
"--ignoreConfig",
],
cwd=str(PROJECT_ROOT),
capture_output=True,
)
for emitted in out.rglob("*.js"):
emitted.write_text(
re.sub(r'(from\s+"\.{1,2}/[^"]+)"', r'\1.js"', emitted.read_text(encoding="utf-8")),
encoding="utf-8",
)
base = next(path.parent for path in out.rglob("B06_Section_Cross_Culvert_Extra.js"))
(base / "runner.mjs").write_text(_RUNNER, encoding="utf-8")
result = tmp_path / "out.json"
subprocess.run( # noqa: S603
["node", str(base / "runner.mjs"), str(result)], check=True, capture_output=True
)
got = json.loads(result.read_text(encoding="utf-8"))
assert (got["deep"]["d"], got["deep"]["x"]) == (6, 2), "관 흙막이 깊이 · 좌우가 되돌아감"
assert got["up"]["d"] == pytest.approx(0), "관 흙막이 윗면이 노면 위로 올라감"
assert got["up"]["topElevation"] == pytest.approx(100), "노면 멈춤 자리 틀림"
assert got["buriedCount"] == 2, "원지반에 묻힌 다단이 끊김"
assert got["buriedD"] == [1, 1], "묻힌 다단의 높이가 되돌아감"
assert got["highCount"] == 2, "원지반 위 다단이 끊김"
assert got["highD"] == [3, 3], "뜬 다단의 높이가 되돌아감"
def test_화면_서버_같은_판() -> None:
for name in (
"logic/B06_Section_UI_Cross_Culvert_Solve",
"logic/B06_Section_Cross_Culvert_Geom",
"B06_Section_UI_Cross_Revetment",
):
source = (B06 / f"{name}.ts").read_text(encoding="utf-8")
assert "requireCrossing" not in source, f"{name} 에 매몰 자리 금지가 남음"
assert "outletReceivable" not in source, f"{name} 에 유출 수용 가드가 남음"
assert "const placeable" not in (B06 / "B06_Section_UI_Cross_Revetment.ts").read_text(
encoding="utf-8"
), "사면안정 흙막이 · 옹벽 매몰 자리 금지가 남음"
assert "const placeable" not in (B06 / "logic/B06_Section_Cross_Culvert_Extra.ts").read_text(
encoding="utf-8"
), "추가 흙막이 매몰 자리 금지가 남음"
bundle = BUNDLE.read_text(encoding="utf-8")
assert "outletReceivable" not in bundle and "requireCrossing" not in bundle, (
"서버 번들이 옛 판 — npm run build:design-calc"
)