Files
Aislo/resources/tester/test_626_1_recommend_preview.py
T
eomsangdonandClaude Opus 5.5 0dbe4d5f31 feat(765-4): 지형 칩 = 벌 맞바꿈 · LAS 나중 올리기 뒤 = 확인창 → 전처리 다시(두 벌 · B05~B09 초기화)
- B05_Profile_Router_TerrainSwitch: 칩 = swap_design_set(떠난 벌 [저장] 고침 살림 · 묶음 없음 · 묵음 = 한 번 지음 · 실패 = 통째 되돌림) · force = switch_terrain → run_surface_change_chain(765-5)
- 확인창 글: 바꿈 = 미리 지어 둔 그 지형 설계로 바꿔 끼움 · 전처리 다시 = 두 벌 새로 · B05~B09 초기화 · LAS 올림 끝 = 늘 전처리 다시
- 시험: test_626_1 칩 시험을 맞바꿈 · 전처리 다시 기준으로(옛 노선 그대로 다시 셈 길 없음) · test_637 force 시험 · 화면 줄 · test_763_3 서피스 바꾸는 자리 목록에 지형 칩

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 15:50:38 +09:00

121 lines
5.3 KiB
Python

"""PLAN 626-1 — 노선 추천 미리보기 · [적용] 걷음 · 지형 바꿈 = 지형 칩(요구 530 · 결정 D1 · D2 · D7 · D8).
- 옛 추천 모달 · 좌측 「노선 추천」 칸 · [적용](`as_initial`) 화면 부름 없음(서버 길 · 시험은 남김).
- 미리보기 = 저장본 넷(영선 · 토공 · 기울기 · 비중) 하나만 · 끔 · 다시 셈(`recompute`) 없음.
- 지형 칩 → `POST /route/design-terrain` — 벌 맞바꿈(765-4 · `swap_design_set`) ·
같은 지형 = 그대로 · `force` = 전처리 다시(765-5).
"""
import asyncio
import re
from pathlib import Path
from uuid import uuid4
from B05_Profile import B05_Profile_Router_Replan as replan
from B05_Profile import B05_Profile_Router_TerrainSwitch as switch
from common_util import common_util_design_sets as sets
ROOT = Path(__file__).resolve().parents[2]
B05 = ROOT / "B05_Profile"
read = lambda path: path.read_text(encoding="utf-8") # noqa: E731
def test_옛_추천_모달_칸_적용_걷음() -> None:
for name in (
"B05_Profile_UI_RouteEdit_Recommend.ts",
"B05_Profile_UI_RouteEdit_Recommend_Help.ts",
"B05_Profile_UI_RouteEdit_Recommend_Map.ts",
"B05_Profile_UI_Panel_Recommend.ts",
"B05_Profile_UI_Style_RouteRecommend.css",
):
assert not (B05 / name).exists(), name
assert "route-recommend" not in read(B05 / "B05_Profile_UI_Panel_Sections.ts")
assert "recommend" not in read(ROOT / "A00_Common" / "design" / "design_view_profile.ts")
# 화면 어디서도 as_initial 을 안 부름(서버 길은 남김)
for path in B05.glob("B05_Profile_UI_*.ts"):
assert "as_initial" not in read(path).replace("`as_initial`", ""), path.name
assert "as_initial" in read(B05 / "B05_Profile_Router_Replan.py")
def test_미리보기_넷_하나만_저장본만() -> None:
src = read(B05 / "B05_Profile_UI_RouteEdit_RecPreview.ts")
modes = re.search(r"const MODES = \[(.*?)\]", src, re.S).group(1)
assert re.findall(r'"(\w+)"', modes) == ["gradeline", "earthwork", "gentle", "weighted"]
# 저장본만 · 다시 셈은 저장본 없을 때 확인창 [지금 셈]만(763-4)
assert src.count("recompute: true") == 1 and "createRoutePreviewMenu({" in src
shared = read(ROOT / "A00_Common" / "map" / "map_route_preview.ts") # 636-2 공용 메뉴 · 그리기
assert "createPickMenu({" in shared and "multi: true" in shared and "offLabel" not in shared
assert "const terrain = opts.terrain();" in src # 지금 설계 지형 저장본(D7)
chrome = read(B05 / "B05_Profile_UI_RouteEdit_Chrome.ts")
assert "recommend: preview.root" in chrome and "terrain: terrain.root" in chrome
menu = read(ROOT / "ui_template" / "ui_template_context_menu.ts")
assert "export function createPickMenu(" in menu and "aria-checked" in menu
def test_지형_칩_확인창_새_길() -> None:
src = read(B05 / "B05_Profile_UI_RouteEdit_Terrain.ts")
assert "askConfirm({" in src and "/route/design-terrain" in src
assert "chip.set(toChip(design))" in src # 취소 · 실패 = 되돌림
assert "rebuildAfterRouteSave(projectId)" in src
def _run(monkeypatch, now: str, want: str, force: bool = False):
"""칩 요청 — 맞바꿈 · 전처리 다시가 받은 값만 잰다(본체 = test_765_design_sets)."""
calls: dict = {}
async def paths(_pid):
return Path("root"), "stored"
async def swap(pid, root, target):
calls["swap"] = (root, target)
if target == now:
return {"changed": False, "design": now}
return {"changed": True, "design": target, "built": False}
async def switch_terrain(_c, _pid, terrain):
calls["switch"] = terrain
return 9
async def chain(pid, model_id):
calls["chain"] = model_id
class Pool:
def acquire(self):
class Ctx:
async def __aenter__(self):
return object()
async def __aexit__(self, *_):
return False
return Ctx()
import B03_FileInput.B03_FileInput_Service_SurfaceChange as change
monkeypatch.setattr(replan, "_project_paths", paths)
monkeypatch.setattr(sets, "swap_design_set", swap)
monkeypatch.setattr(sets, "switch_terrain", switch_terrain)
monkeypatch.setattr(change, "run_surface_change_chain", chain)
monkeypatch.setattr(switch, "get_db_pool", lambda: Pool())
body = switch.DesignTerrainRequest(terrain=want, force=force)
result = asyncio.run(switch.switch_route_design_terrain(uuid4(), body))
return result, calls
def test_지형_바꿈_벌_맞바꿈(monkeypatch) -> None:
result, calls = _run(monkeypatch, "las", "sheet")
assert result["changed"] is True and result["design"] == "sheet"
assert calls == {"swap": (Path("root"), "sheet")} # 전처리 다시 아님
def test_같은_지형이면_그대로(monkeypatch) -> None:
result, calls = _run(monkeypatch, "sheet", "sheet")
assert result == {"status": "success", "design": "sheet", "changed": False}
assert "chain" not in calls
def test_force_는_전처리_다시(monkeypatch) -> None:
result, calls = _run(monkeypatch, "las", "las", force=True)
assert result["preprocessed"] is True and result["design"] == "las"
assert calls == {"switch": "las", "chain": 9} # 맞바꿈 아님 · 두 벌 다시