Merge remote-tracking branch 'origin/sub_laptop_7' into main_laptop_1
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
"""높이 제약 풀기(54-51) — 관 흙막이 · 추가 흙막이 · 사면안정 흙막이 · 옹벽 · 집수정 높이를 사용자 값 그대로.
|
||||
|
||||
남는 규칙: 그림이 안 서는 값(순수 높이 0 이하)만 0.1 에서 멈춤 · 토스트 없음.
|
||||
서버 면적은 같은 TS 를 Node 로 돌림(`B06_Section_Server_Calc_Node.ts`) — 번들도 같은 판인지 봄.
|
||||
"""
|
||||
|
||||
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" / "server_calc_node" / "B06_Section_Server_Calc_Node.js"
|
||||
|
||||
_RUNNER = """
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { revetWallSpec } from "./B06_Section_UI_Cross_Culvert_Const.js";
|
||||
import { buildOutletExtras } from "./B06_Section_UI_Cross_Culvert_Extra.js";
|
||||
const spec = { revet_form: "찰쌓기", revet_height_m: 1.5 };
|
||||
const pipe = (h) => revetWallSpec(spec, { h, m: null }, false, 0.8).pureHeight;
|
||||
const own = (h) => revetWallSpec(spec, { h, m: null }, true, 0).pureHeight;
|
||||
const extras = buildOutletExtras({
|
||||
start: { offset: 10, elevation: 95 }, startBottomElevation: 94.5, outward: 1,
|
||||
groundAt: () => 80, limitOffset: 40,
|
||||
adjusts: [{ x: 0, d: 0, h: 0.3, m: null }],
|
||||
});
|
||||
writeFileSync(process.argv[2], JSON.stringify({
|
||||
pipeLow: pipe(0.7), pipeAuto: pipe(null), pipeZero: pipe(0),
|
||||
ownLow: own(0.3), ownNeg: own(-1),
|
||||
extraCount: extras.walls.length,
|
||||
extraPure: extras.walls.map((w) => w.topBack.elevation - w.bottomBack.elevation),
|
||||
}));
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.skipif(not TSC.is_file(), reason="프론트엔드 의존성 미설치")
|
||||
def test_높이는_입력_그대로_0이하만_멈춤(tmp_path: Path) -> None:
|
||||
out = tmp_path / "js"
|
||||
for name in ("Culvert_Const", "Culvert_Extra"):
|
||||
subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
[
|
||||
"node",
|
||||
str(TSC),
|
||||
str(B06 / f"B06_Section_UI_Cross_{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+"\./[^"]+)"', r'\1.js"', emitted.read_text(encoding="utf-8")),
|
||||
encoding="utf-8",
|
||||
)
|
||||
base = next(path.parent for path in out.rglob("B06_Section_UI_Cross_Culvert_Const.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["pipeLow"] == pytest.approx(0.7), "관 흙막이가 관경 기준 최소로 되돌아감"
|
||||
assert got["pipeAuto"] == pytest.approx(1.8), "빈 칸 기본값(관경 + 1.0) 틀림"
|
||||
assert got["pipeZero"] == pytest.approx(0.1), "0 이하가 그림 하한에서 안 멈춤"
|
||||
assert got["ownLow"] == pytest.approx(0.3), "흙막이 0.3 이 근입 기준 최소로 되돌아감"
|
||||
assert got["ownNeg"] == pytest.approx(0.1), "음수 높이가 그림 하한에서 안 멈춤"
|
||||
assert got["extraCount"] == 1, "낮은 추가 흙막이가 안 섬"
|
||||
assert got["extraPure"][0] == pytest.approx(0.3), "추가 흙막이 0.3 이 되돌아감"
|
||||
|
||||
|
||||
def test_높이_토스트_없음_서버_같은_판() -> None:
|
||||
for name in ("UI_Cross_Culvert_Wire", "UI_Page_Pipe_Options"):
|
||||
source = (B06 / f"B06_Section_{name}.ts").read_text(encoding="utf-8")
|
||||
assert "B06_Cross_Height_Floor" not in source, f"{name} 에 최소 높이 토스트가 남음"
|
||||
assert "높이는 최소" not in source, f"{name} 에 최소 높이 토스트가 남음"
|
||||
panel = (B06 / "B06_Section_UI_Cross_Structure_Panel.ts").read_text(encoding="utf-8")
|
||||
assert "Math.min(\n 2," not in panel, "집수정 내공 2m 상한이 남음"
|
||||
bundle = BUNDLE.read_text(encoding="utf-8")
|
||||
assert "EXTRA_WALL_MIN_HEIGHT_M" not in bundle, "서버 번들이 옛 판 — npm run build:server-calc"
|
||||
assert "WALL_MIN_PURE_HEIGHT_M" in bundle, "서버 번들이 옛 판 — npm run build:server-calc"
|
||||
Reference in New Issue
Block a user