- 노선 초안 시작 때 저장 상세 사본 · 측점 열쇠 · 횡단 초안 칸 다섯을 떠 둠(holdDraft · holdSectionDetail) — 버리면 그것으로 되돌림 - 묶음 측점이 저장 상세와 달라도 갈아끼움 대신 초안 전 상세 · 묶음 기록에 첫 다른 측점 · 개수(restoreDiff · restoreWhy saved-diff) - 되돌린 사본이 묶음 저장 정본 — 다시 하기 · 다시 열기 없이 같은 기준 - 측점 갈아끼움이 앞 상세와 설계 객체를 같이 안 씀 — 면적 얹기 · 다시 셈이 저장 상세를 제자리로 안 고침 - 횡단 다시 셈 창구가 묶음 새 노선 상세(preview)는 안 고침 — 묶음 cross 결과 그대로 - 시험 test_349_0o_redo_same 6(열기 · 끌기 · 되돌리기 · 다시 하기 · 되돌리기 · 횡단 보기 · 종단 보기 · 진짜 Design_Sync 판정) · 0k · 0l 헬퍼 새 길로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
197 lines
7.7 KiB
Python
197 lines
7.7 KiB
Python
"""PLAN 349-0o sub7 — 값 한 벌: 되돌림 · 다시 하기 · 횡단 보기가 같은 값.
|
|
|
|
· 열기 → 끌기 → 되돌리기 → 다시 하기 → 되돌리기 → 횡단 보기 → 종단 보기 =
|
|
열기 · 끌기 · 열기 · 끌기 · 열기 · 열기 · 열기 값(누가토량 · 횡단 · 측점)
|
|
· 저장 상세에 없는 세월교 측점(묶음 측점 ≠ 상세 측점) — 되돌림 = 초안 전 상세 · 묶음 기록에 첫 다른 측점 · 개수
|
|
· 횡단 초안 칸(카드 선택 · 단면 유형) = 열기 값 — 초안 동안 넘김이 버린 칸도
|
|
· 횡단 보기 진입 다시 셈 판정은 진짜(`Design_Sync`) — 되돌린 뒤 다시 셈 0
|
|
· 되돌리기 · 다시 하기 = 화면 꼴(세션 노선 초안 칸 먼저 · 알림 두 번)
|
|
짝: `helper_349_0o_redo_same.cjs`(실제 TS 를 Node 로 · 화면 부품 · 서버 창구만 가짜).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import csv
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
ROOT = HERE.parents[1]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from B05_Profile.B05_Profile_Structures_Schema import structure_type_map # noqa: E402
|
|
from common_util.common_util_surface_sampler import dtm_grid_bytes # noqa: E402
|
|
from config.config_system_design import STANDARD_CROSS_SECTION # noqa: E402
|
|
|
|
pytestmark = pytest.mark.skipif(
|
|
not (ROOT / "config" / "node_modules" / "typescript").is_dir(),
|
|
reason="프론트엔드 의존성 미설치",
|
|
)
|
|
|
|
PROJECT = ROOT / "storage/1/3/6d3b2812-6d5a-4168-a932-40e4ae303d5a" # 검증_sub7
|
|
ROUTE = PROJECT / "B05_Profile/route"
|
|
SECTION = PROJECT / "B06_Section"
|
|
GRID = PROJECT / "B04_PreProcess/models/dtm_classification_smooth.npz"
|
|
ONES = {g: {"loose": 1.0, "compacted": 1.0} for g in ("soil", "ripping_rock", "blasting_rock")}
|
|
|
|
|
|
def _csv(path: Path) -> list[list[float]]:
|
|
with path.open(encoding="utf-8") as handle:
|
|
return [[float(r["x"]), float(r["y"])] for r in csv.DictReader(handle)]
|
|
|
|
|
|
def _json(path: Path):
|
|
return json.loads(path.read_text(encoding="utf-8"))
|
|
|
|
|
|
def _between(sections: list[dict], index: int) -> dict:
|
|
"""두 측점 사이 한 점(0.37) — 누가거리 · 좌표."""
|
|
a, b = sections[index], sections[index + 1]
|
|
k = 0.37
|
|
return {
|
|
"chainage_m": round(a["chainage_m"] + k * (b["chainage_m"] - a["chainage_m"]), 2),
|
|
"x": a["center_x"] + k * (b["center_x"] - a["center_x"]),
|
|
"y": a["center_y"] + k * (b["center_y"] - a["center_y"]),
|
|
}
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def r() -> dict:
|
|
if not (GRID.is_file() and (SECTION / "longitudinal/longitudinal.json").is_file()):
|
|
pytest.skip("검증_sub7 없음")
|
|
curves = _json(ROUTE / "planned_route_curves.json")
|
|
sections = sorted(
|
|
(_json(p) for p in (SECTION / "cross_sections").glob("cross_*.json")),
|
|
key=lambda s: s["chainage_m"],
|
|
)
|
|
pipes = _json(PROJECT / "B04_PreProcess/drainage/edits/pipe_points.json")["points"]
|
|
# 세월교 하나 더(측점 사이) — 저장 상세엔 그 측점이 없음 = 묶음 저장 노선 측점과 다름(검증_sub7 세월교 2 + 1)
|
|
pipes = [*pipes, {"source": "manual", "facility": "ford_bridge", **_between(sections, -6)}]
|
|
# 저장 횡단 면적 = 서버가 상세를 낼 때 셈(파일엔 없음) — 정본 대신 정한 값
|
|
for i, section in enumerate(sections):
|
|
section["design"] = {
|
|
"ground_type": "soil",
|
|
"design_elevation_m": section["center_z"],
|
|
"cut_area_m2": 4.0 + (i % 5),
|
|
"fill_area_m2": 1.5 + (i % 3),
|
|
}
|
|
job = {
|
|
"line": _csv(ROUTE / "planned_route.csv"),
|
|
"nodes": _csv(ROUTE / "planned_route_nodes.csv"),
|
|
"curves": [
|
|
{k: c[k] for k in ("start", "apex", "end", "radius_m")} for c in curves["curves"]
|
|
],
|
|
"stationSnap": bool(curves.get("station_snap")),
|
|
"minRadius": curves["min_radius_m"],
|
|
"interval": 20.0,
|
|
"types": [
|
|
{"type_id": t.type_id, "group": t.group, "placement": t.placement}
|
|
for t in structure_type_map().values()
|
|
],
|
|
"pipes": pipes,
|
|
"standard": STANDARD_CROSS_SECTION,
|
|
"conversion": ONES,
|
|
# 구조물 하나 — 첫 관 자리 횡단배수(같은 측점을 덮음)
|
|
"structures": [
|
|
{
|
|
"structure_id": "s-349o",
|
|
"type_id": "cross_drain_exposed",
|
|
"chainage_m": pipes[0]["chainage_m"],
|
|
"x": pipes[0]["x"],
|
|
"y": pipes[0]["y"],
|
|
}
|
|
],
|
|
# 열기 전에 고친 카드 선택 — 끌면 밀리는 측점(뒤쪽) · 단면 유형은 노선이 바뀌면 안 넘기는 칸
|
|
"touched": {
|
|
str(sections[-3]["chainage_m"]): {
|
|
"ground_type": "blasting_rock",
|
|
"section_mode": "right_cut",
|
|
}
|
|
},
|
|
"detail": {
|
|
"longitudinal": _json(SECTION / "longitudinal/longitudinal.json"),
|
|
"cross_sections": sections,
|
|
},
|
|
}
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
path = Path(folder) / "job.json"
|
|
path.write_text(json.dumps(job), encoding="utf-8")
|
|
grid = Path(folder) / "grid.bin"
|
|
grid.write_bytes(dtm_grid_bytes(GRID))
|
|
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
|
|
["node", str(HERE / "helper_349_0o_redo_same.cjs"), str(path), str(grid)],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=300,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def _same(a: dict, b: dict) -> None:
|
|
assert a["final"] == b["final"]
|
|
assert a["cross"] == b["cross"]
|
|
|
|
|
|
def test_열기(r):
|
|
o = r["open"]
|
|
assert [x["outcome"] for x in o["runs"]] == ["done"], o["runs"]
|
|
assert o["lastKey"] == "" and o["drawnSaved"] and o["refresh"] == 0
|
|
assert o["final"] is not None
|
|
|
|
|
|
def test_끌기_새_노선(r):
|
|
d = r["first"]
|
|
assert [x["sources"] for x in d["runs"]] == [["route"]], d["runs"]
|
|
assert not d["drawnSaved"] # 묶음 새 노선 상세를 그림
|
|
assert d["final"] != r["open"]["final"]
|
|
|
|
|
|
def test_되돌리기_열기_값_측점_다름은_기록(r):
|
|
o = r["open"]
|
|
for u in (r["back1"], r["back2"]):
|
|
assert [(x["sources"], x["restored"], x["why"]) for x in u["runs"]] == [
|
|
(["route"], True, "saved-diff")
|
|
], u["runs"]
|
|
assert u["refresh"] == 0
|
|
assert u["lastKey"] == "" and u["drawnSaved"] and u["drawnLive"]
|
|
assert u["stations"] == o["stations"]
|
|
_same(u, o)
|
|
assert u["edits"] == o["edits"]
|
|
assert u["cells"] == o["cells"] # 횡단 초안 칸 = 열기 값
|
|
diffs = r["restoreDiffs"]
|
|
assert len(diffs) == 2 and diffs[0] == diffs[1]
|
|
d = diffs[0]
|
|
assert d["pipeline"] == d["saved"] + 1 # 세월교 측점 하나 더
|
|
assert d["pipelineM"] is not None and d["savedM"] is not None
|
|
|
|
|
|
def test_초안_상세는_다시_셈이_안_고침(r):
|
|
for step in (r["first"], r["redo"]):
|
|
assert step["draftRefresh"] == {"updated": [], "same": True}
|
|
|
|
|
|
def test_다시_하기_첫_끌기_값(r):
|
|
d, f = r["redo"], r["first"]
|
|
assert [x["sources"] for x in d["runs"]] == [["route"]], d["runs"]
|
|
_same(d, f)
|
|
assert d["stations"] == f["stations"]
|
|
|
|
|
|
def test_횡단_보기_다녀와도_열기_값(r):
|
|
o = r["open"]
|
|
for step in (r["cross"], r["back"]):
|
|
assert step["runs"] == [], step["runs"]
|
|
assert step["refresh"] == 0 # 진입 다시 셈 판정 · crossPreview 모두 안 돎
|
|
assert step["lastKey"] == "" and step["drawnSaved"]
|
|
_same(step, o)
|
|
assert step["cells"] == o["cells"]
|
|
assert r["blocked"] == 0
|