Merge remote-tracking branch 'origin/sub_laptop_2' into main_laptop_1
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/* 472-4 C6 거울 헬퍼 — 맹암거 얹기 TS 짝(vite ssr) · test_472_4_underdrain_mirror.py 가 JSON 으로 받음. */
|
||||
export {
|
||||
attachUnderdrainSpecs,
|
||||
underdrainSpecsFrom,
|
||||
} from "../../common_util/common_util_structure_underdrain";
|
||||
@@ -42,8 +42,11 @@ def test_글은_재계산에서도_남는다(monkeypatch):
|
||||
monkeypatch.setattr(design_mod, "ford_surface_drops", lambda root: [])
|
||||
monkeypatch.setattr(design_mod, "design_elevation_from_longitudinal", lambda lon, ch: 100.0)
|
||||
monkeypatch.setattr(design_mod, "curve_widening_args", lambda section: {})
|
||||
# 472-4 ② — [저장] 다시 셈은 측점 묶음(Node) 한 번 · 그 자리를 갈아 끼움
|
||||
monkeypatch.setattr(
|
||||
design_mod, "compute_cross_design", lambda samples, elev, **kw: {"paved": kw["paved"]}
|
||||
design_mod,
|
||||
"compute_cross_designs",
|
||||
lambda jobs, standard: [{"paved": kw["paved"]} for _s, _z, kw in jobs],
|
||||
)
|
||||
sections = [{"chainage_m": 40.0, "design": {"paved": False, "structure_note": "메모"}}]
|
||||
assert design_mod.enforce_pavement_ranges({}, sections, Path("."), None) == 1
|
||||
|
||||
@@ -202,7 +202,8 @@ def test_좌측_패널_칸_구간_깊이_나름():
|
||||
"""옛 구조물 옵션 depth_m → 세션 구간 → 측점 제원(기본값) · 서버 payload(같은 꼴).
|
||||
|
||||
좌측 칸은 194-1 에서 숨김 — 옮기기는 횡단도 ▲▼(`test_194_1_berm_depth`)."""
|
||||
source = (ROOT / "B06_Section" / "B06_Section_UI_Page_Persist.ts").read_text(encoding="utf-8")
|
||||
# 소단 구간 셈은 472-4 C4 에서 `common_util_berm_spans.ts` 로 옮김
|
||||
source = (ROOT / "common_util" / "common_util_berm_spans.ts").read_text(encoding="utf-8")
|
||||
assert "options.depth_m" in source and "Math.max(rawDepth, 0)" in source
|
||||
refresh = (ROOT / "B06_Section" / "B06_Section_Cross_Refresh.ts").read_text(encoding="utf-8")
|
||||
assert "depthM: spec.depth_m" in refresh
|
||||
|
||||
@@ -59,8 +59,11 @@ def test_CAD_칸은_재계산에서도_남는다(monkeypatch):
|
||||
monkeypatch.setattr(design_mod, "ford_surface_drops", lambda root: [])
|
||||
monkeypatch.setattr(design_mod, "design_elevation_from_longitudinal", lambda lon, ch: 100.0)
|
||||
monkeypatch.setattr(design_mod, "curve_widening_args", lambda section: {})
|
||||
# 472-4 ② — [저장] 다시 셈은 측점 묶음(Node) 한 번 · 그 자리를 갈아 끼움
|
||||
monkeypatch.setattr(
|
||||
design_mod, "compute_cross_design", lambda samples, elev, **kw: {"paved": kw["paved"]}
|
||||
design_mod,
|
||||
"compute_cross_designs",
|
||||
lambda jobs, standard: [{"paved": kw["paved"]} for _s, _z, kw in jobs],
|
||||
)
|
||||
sections = [{"chainage_m": 40.0, "design": {"paved": False, "structure_note_cad": CAD}}]
|
||||
assert design_mod.enforce_pavement_ranges({}, sections, Path("."), None) == 1
|
||||
|
||||
@@ -26,6 +26,7 @@ if str(ROOT) not in sys.path:
|
||||
import B05_Profile.B05_Profile_Structures_Repository as structures_repo # noqa: E402
|
||||
import B06_Section.B06_Section_Engine_Tilt as tilt_mod # noqa: E402
|
||||
import B06_Section.B06_Section_Router_Design as design_mod # noqa: E402
|
||||
import B06_Section.B06_Section_Router_Design_Ranges as ranges_mod # noqa: E402
|
||||
from B05_Profile.B05_Profile_Structures_Schema import StructureInstance # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Culvert import culvert_sets_from # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Design import compute_cross_design # noqa: E402
|
||||
@@ -157,7 +158,8 @@ def server(r) -> list[dict]:
|
||||
"""서버 [확정] 차례 그대로 — 저장분(보정 전) → 포장 구간 → 세월교 하강."""
|
||||
patch = pytest.MonkeyPatch()
|
||||
sets = culvert_sets_from(parse_pipe_points(PIPES))
|
||||
for module in (design_mod, tilt_mod):
|
||||
# 구간 읽기는 472-4 에서 `_Router_Design_Ranges` 로 나눔 — 정본 읽기를 그 모듈에서 갈아 끼움.
|
||||
for module in (ranges_mod, tilt_mod):
|
||||
patch.setattr(module, "load_culvert_sets", lambda _root: sets)
|
||||
patch.setattr(module, "load_structures", lambda _root: (0, STRUCTURES))
|
||||
patch.setattr(structures_repo, "load_structures", lambda _root: (0, STRUCTURES))
|
||||
|
||||
@@ -27,6 +27,7 @@ from test_349_0n_cross_enforce_mirror import OFFSETS, _stations, _z # noqa: E40
|
||||
import B05_Profile.B05_Profile_Structures_Repository as structures_repo # noqa: E402
|
||||
import B06_Section.B06_Section_Engine_Tilt as tilt_mod # noqa: E402
|
||||
import B06_Section.B06_Section_Router_Design as design_mod # noqa: E402
|
||||
import B06_Section.B06_Section_Router_Design_Ranges as ranges_mod # noqa: E402
|
||||
from B05_Profile.B05_Profile_Structures_Schema import StructureInstance # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Culvert import culvert_sets_from # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Design import compute_cross_design # noqa: E402
|
||||
@@ -109,7 +110,8 @@ def server(r) -> list[dict]:
|
||||
"""서버 [확정] — 저장분(입력 없는 측점은 config 암 경계) → 포장 구간 → 세월교 하강."""
|
||||
patch = pytest.MonkeyPatch()
|
||||
sets = culvert_sets_from(parse_pipe_points(PIPES))
|
||||
for module in (design_mod, tilt_mod):
|
||||
# 구간 읽기는 472-4 에서 `_Router_Design_Ranges` 로 나눔 — 정본 읽기를 그 모듈에서 갈아 끼움.
|
||||
for module in (ranges_mod, tilt_mod):
|
||||
patch.setattr(module, "load_culvert_sets", lambda _root: sets)
|
||||
patch.setattr(module, "load_structures", lambda _root: (0, STRUCTURES))
|
||||
patch.setattr(structures_repo, "load_structures", lambda _root: (0, STRUCTURES))
|
||||
|
||||
@@ -19,6 +19,7 @@ X3 면적 두 갈래(구조물 = 관 351 하나 · 두 길 다 Node TS 로 셈)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -131,6 +132,25 @@ def test_두_길_사이_알려진_차만(got, pair) -> None:
|
||||
assert not gone, f"안 나타난 알려진 차 {gone} — KNOWN 에서 지움"
|
||||
|
||||
|
||||
def test_저장_설계선_점_정본과_1e4_안(tmp_path) -> None:
|
||||
"""[저장] 다시 셈 설계선(472-4 ② = Node TS) — 정본과 점 수 · offset 같음 · 고도 1e-4 m 안.
|
||||
|
||||
알려진 차 = 반올림 동점(파이썬 round 짝수 쪽 · TS 위쪽) 13 점(브레인 10-19 승인).
|
||||
"""
|
||||
detail = copy.deepcopy(paths.read("detail.json"))
|
||||
before = {s["chainage_m"]: s["design"]["design_line"] for s in detail["cross_sections"]}
|
||||
sections, _ = paths._save_tail(detail, paths.stage_project(tmp_path / "project"))
|
||||
moved = 0
|
||||
for section in sections:
|
||||
old, new = before[section["chainage_m"]], section["design"]["design_line"]
|
||||
assert [p["offset_m"] for p in new] == [p["offset_m"] for p in old], section["chainage_m"]
|
||||
for a, b in zip(old, new, strict=True):
|
||||
gap = abs(a["elevation_m"] - b["elevation_m"])
|
||||
assert gap <= 1e-4 + 1e-9, (section["chainage_m"], a, b)
|
||||
moved += gap > 0
|
||||
assert moved == 13, f"반올림 동점 점 수 {moved} — 알려진 차(13)와 다름"
|
||||
|
||||
|
||||
def test_화면_참값() -> None:
|
||||
stored = GOLDEN["stored"]
|
||||
assert stored["final_cumulative_m3"] == -17570.7
|
||||
|
||||
@@ -40,6 +40,8 @@ NODE_IDS = {
|
||||
"haul.plan",
|
||||
"excavation.trench",
|
||||
"corridor.mesh",
|
||||
"cross.design",
|
||||
"cross.berm_spans",
|
||||
}
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
@@ -196,7 +198,7 @@ def test_id_마다_실행기_있음(loaded) -> None:
|
||||
if row["site"] == "browser_only":
|
||||
ok = kind == "browser" and _has_name(ref)
|
||||
elif kind == "node":
|
||||
ok = ref == row["id"] and ref in NODE_IDS
|
||||
ok = ref in NODE_IDS # 한 셈에서 나오는 값(면적 · 소단 사면)은 그 셈의 id
|
||||
else:
|
||||
ok = kind == "py" and _has_name(ref)
|
||||
ok = ok and ("until" not in row or kind == "py")
|
||||
@@ -205,8 +207,10 @@ def test_id_마다_실행기_있음(loaded) -> None:
|
||||
if not ok:
|
||||
bad.append(row["id"])
|
||||
assert bad == []
|
||||
node_rows = {row["id"] for row in loaded["registry"] if row["runner"].startswith("node:")}
|
||||
assert node_rows == NODE_IDS
|
||||
node_runs = {
|
||||
row["runner"][5:] for row in loaded["registry"] if row["runner"].startswith("node:")
|
||||
}
|
||||
assert node_runs == NODE_IDS
|
||||
|
||||
|
||||
def test_묶음_STAGE_DEPS_등록부_입력과_같음(loaded) -> None:
|
||||
|
||||
@@ -68,3 +68,36 @@ def test_실행기_값_server_calc_와_같음() -> None:
|
||||
def test_Node_실행기_아닌_id_는_ValueError() -> None:
|
||||
with pytest.raises(ValueError, match="stations.list"):
|
||||
runner.run_calc(["masshaul.cumulative", "stations.list"], {})
|
||||
|
||||
|
||||
# ── 472-4 ② — 횡단 설계선 · 소단 구간 Node 길 ──────────────────────────────────
|
||||
|
||||
|
||||
def test_소단_구간_Node_와_파이썬_짝_같음(tmp_path, monkeypatch) -> None:
|
||||
from test_272_berm_source import STRUCTURE_CASES, _project
|
||||
|
||||
from B06_Section import B06_Section_Engine_Design_Node as node_mod
|
||||
from B06_Section.B06_Section_Engine_Structures_Wall import berm_span_at, load_berm_spans
|
||||
|
||||
calls = []
|
||||
real = node_mod.run_calc
|
||||
monkeypatch.setattr(
|
||||
node_mod, "run_calc", lambda ids, inputs: calls.append(ids) or real(ids, inputs)
|
||||
)
|
||||
chainages = [0.0, 5.0, 50.0, 65.0, 80.0, 100.0, 150.0, 250.0]
|
||||
for index, structures in enumerate(STRUCTURE_CASES):
|
||||
root = _project(tmp_path / f"c{index}", structures)
|
||||
got = node_mod.berm_specs_at(root, chainages)
|
||||
spans = load_berm_spans(root)
|
||||
want = [berm_span_at(spans, c) for c in chainages]
|
||||
assert got == [pytest.approx(w) if w else w for w in want], index
|
||||
assert len(calls) == len(STRUCTURE_CASES) # 파이썬 물러섬 아님
|
||||
|
||||
|
||||
def test_횡단_설계_못_세운_측점은_None() -> None:
|
||||
from B06_Section.B06_Section_Engine_Design_Node import compute_cross_designs
|
||||
|
||||
ground = [{"offset_m": o, "elevation_m": 100.0 + 0.3 * o} for o in range(-20, 21)]
|
||||
options = {"ground_type": "soil", "section_mode": "left_cut"}
|
||||
got = compute_cross_designs([(ground, 100.0, options), (ground, None, options)], None)
|
||||
assert got[0]["cut_area_m2"] > 0 and got[1] is None
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
"""PLAN 472-4 ② C6 (요구 273) — 맹암거 얹기 거울: TS `common_util_structure_underdrain` ↔ 파이썬
|
||||
`B06_Section_Engine_Tilt.underdrains_from` · `attach_underdrain_specs`.
|
||||
|
||||
못박는 것
|
||||
- 구조물 목록 → 제원(높이 · 경사 · 빈 값 · 0 · 음수 · 글 · 맹암거 아닌 종류) 두 쪽 같음.
|
||||
- 기준 측점(±0.02 m) 얹기 · 얹은 수 같음.
|
||||
- 알려진 차 하나 — 옛 `underdrain` 이 남은 측점: TS 는 걷음 · 파이썬은 둠
|
||||
(서버는 파일에서 새로 읽어 옛 값 없음 · Node 로 옮길 때 한 벌).
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_472_4_underdrain_mirror.py -q
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from B05_Profile.B05_Profile_Structures_Schema import StructureInstance
|
||||
from B06_Section.B06_Section_Engine_Tilt import attach_underdrain_specs, underdrains_from
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not (ROOT / "config" / "node_modules" / "vite").is_dir(),
|
||||
reason="프론트엔드 의존성 미설치",
|
||||
)
|
||||
|
||||
|
||||
def _drain(at: float, **options) -> dict:
|
||||
return {
|
||||
"type_id": "cross_underdrain",
|
||||
"placement": "point",
|
||||
"chainage_m": at,
|
||||
"options": options,
|
||||
}
|
||||
|
||||
|
||||
STRUCTURES = [
|
||||
_drain(40.0, culvert_height_m=1.2, culvert_slope_pct=3),
|
||||
_drain(80.0, culvert_height_m="", culvert_slope_pct="2.5"),
|
||||
_drain(120.0, culvert_height_m=0, culvert_slope_pct=-1),
|
||||
_drain(160.0),
|
||||
{"type_id": "berm", "placement": "interval", "start_m": 0.0, "end_m": 50.0, "options": {}},
|
||||
]
|
||||
SECTIONS = [
|
||||
{"chainage_m": 40.01},
|
||||
{"chainage_m": 79.99},
|
||||
{"chainage_m": 120.0},
|
||||
{"chainage_m": 160.03}, # 0.02 밖
|
||||
{"chainage_m": 200.0, "underdrain": {"chainage_m": 200.0}}, # 옛 값 — 알려진 차
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def ts(tmp_path_factory) -> dict:
|
||||
work = tmp_path_factory.mktemp("u4724")
|
||||
subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
[
|
||||
"node",
|
||||
str(ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"),
|
||||
"build",
|
||||
"--configLoader",
|
||||
"runner",
|
||||
"--ssr",
|
||||
"../resources/tester/helper_472_4_underdrain_entry.ts",
|
||||
"--outDir",
|
||||
str(work),
|
||||
"--logLevel",
|
||||
"error",
|
||||
],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
timeout=300,
|
||||
)
|
||||
bundle = work / "bundle.mjs"
|
||||
shutil.copy(work / "helper_472_4_underdrain_entry.js", bundle)
|
||||
job = json.dumps({"structures": STRUCTURES, "sections": SECTIONS})
|
||||
script = (
|
||||
f"const m = await import({json.dumps(bundle.as_uri())});"
|
||||
f"const job = {job};"
|
||||
"const specs = m.underdrainSpecsFrom(job.structures);"
|
||||
"const count = m.attachUnderdrainSpecs(job.sections, specs);"
|
||||
"console.log(JSON.stringify({specs, count, sections: job.sections}));"
|
||||
)
|
||||
out = subprocess.run( # noqa: S603
|
||||
["node", "--input-type=module", "-e", script],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=60,
|
||||
)
|
||||
return json.loads(out.stdout)
|
||||
|
||||
|
||||
def _python() -> tuple[list[dict], int, list[dict]]:
|
||||
specs = underdrains_from([StructureInstance(**item) for item in STRUCTURES])
|
||||
sections = copy.deepcopy(SECTIONS)
|
||||
return specs, attach_underdrain_specs(sections, specs), sections
|
||||
|
||||
|
||||
def test_제원_같음(ts) -> None:
|
||||
specs, _count, _sections = _python()
|
||||
assert ts["specs"] == specs
|
||||
|
||||
|
||||
def test_얹기_같음_알려진_차_하나(ts) -> None:
|
||||
_specs, count, sections = _python()
|
||||
assert ts["count"] == count == 3
|
||||
assert ts["sections"][:4] == sections[:4]
|
||||
# 알려진 차 — 옛 underdrain: TS 걷음 · 파이썬 둠
|
||||
assert "underdrain" not in ts["sections"][4] and "underdrain" in sections[4]
|
||||
@@ -31,6 +31,8 @@ TSC = PROJECT_ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc"
|
||||
|
||||
# 값이 소수점 아래에서 갈리는지 보려면 자릿수를 그대로 비교해야 한다. 두 쪽 다 반올림해
|
||||
# 내보내므로 완전 일치를 기대하되, 부동소수 마지막 자리만 어긋나는 것은 허용한다.
|
||||
# 알려진 차(472-4 ②) — 반올림 동점(…5)에서 파이썬 round 는 짝수 쪽 · TS 는 위쪽이라 설계선 점이
|
||||
# 1e-4 m 갈릴 수 있음(이 시험 입력엔 없음 · [저장] 정본은 Node TS 쪽 · test_472_1_golden).
|
||||
_TOLERANCE = 1e-9
|
||||
|
||||
|
||||
|
||||
@@ -146,8 +146,11 @@ def test_enforce_turns_paved_on_and_off(monkeypatch):
|
||||
monkeypatch.setattr(design_mod, "ford_surface_drops", lambda root: [])
|
||||
monkeypatch.setattr(design_mod, "design_elevation_from_longitudinal", lambda lon, ch: 100.0)
|
||||
monkeypatch.setattr(design_mod, "curve_widening_args", lambda section: {})
|
||||
# 472-4 ② — [저장] 다시 셈은 측점 묶음(Node) 한 번 · 그 자리를 갈아 끼움
|
||||
monkeypatch.setattr(
|
||||
design_mod, "compute_cross_design", lambda samples, elev, **kw: {"paved": kw["paved"]}
|
||||
design_mod,
|
||||
"compute_cross_designs",
|
||||
lambda jobs, standard: [{"paved": kw["paved"]} for _s, _z, kw in jobs],
|
||||
)
|
||||
sections = [
|
||||
{"chainage_m": 20.0, "design": {"paved": False}}, # 범위 안 · 끔 → 켬
|
||||
|
||||
@@ -80,7 +80,12 @@ def _install_fakes(monkeypatch) -> dict:
|
||||
}
|
||||
|
||||
monkeypatch.setattr(design_mod, "pavement_ranges", lambda root: [(0.0, 200.0)])
|
||||
monkeypatch.setattr(design_mod, "compute_cross_design", fake_compute)
|
||||
# 472-4 ② — [저장] 다시 셈은 측점 묶음(Node) 한 번 · 그 자리를 갈아 끼움
|
||||
monkeypatch.setattr(
|
||||
design_mod,
|
||||
"compute_cross_designs",
|
||||
lambda jobs, standard: [fake_compute(s, z, standard=standard, **kw) for s, z, kw in jobs],
|
||||
)
|
||||
monkeypatch.setattr(design_mod, "design_elevation_from_longitudinal", lambda lon, ch: 100.0)
|
||||
monkeypatch.setattr(design_mod, "curve_widening_args", lambda section: {})
|
||||
return seen
|
||||
|
||||
@@ -120,7 +120,12 @@ def _fake_engine(monkeypatch):
|
||||
return {"paved": True, "cut_area_m2": 1.0, "fill_area_m2": 2.0}
|
||||
|
||||
monkeypatch.setattr(design_mod, "pavement_ranges", lambda root: [(0.0, 200.0)])
|
||||
monkeypatch.setattr(design_mod, "compute_cross_design", fake_compute)
|
||||
# 472-4 ② — [저장] 다시 셈은 측점 묶음(Node) 한 번 · 그 자리를 갈아 끼움
|
||||
monkeypatch.setattr(
|
||||
design_mod,
|
||||
"compute_cross_designs",
|
||||
lambda jobs, standard: [fake_compute(s, z, standard=standard, **kw) for s, z, kw in jobs],
|
||||
)
|
||||
monkeypatch.setattr(design_mod, "design_elevation_from_longitudinal", lambda lon, ch: 100.0)
|
||||
monkeypatch.setattr(design_mod, "curve_widening_args", lambda section: {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user