Files
Aislo/resources/tester/test_364_4_precompute_on_open.py
T
eomsangdonandClaude Opus 5.5 99ec4b8efe feat(B05 평면 지도): 공용 도구줄 표 · 겹 줄 · 범례 · 지형 칩 붙임 · 노선추천 = 도구줄 미리보기(넷 · 하나만 · 끔) · [적용] · 추천 모달 · 좌측 칸 걷음 · 지형 바꿈 = 지형 칩 (PLAN 624-3 · 626-1 · 요구 530 · 531)
- 624-3 도구줄 = 공용 표 「b05」 · 아래 줄 = 공용 겹 줄(띠 · 올린 임도망도 숨김 · 처음 = 등고선 · 하천) · 범례 = 공용 legendRows(상태 글판 위)
- 노선 띠 300 m 자르기 = B05 자기 칸(등고선 · 하천 · 1 m)만 · 그 밖 겹 = 안 자르는 둘째 GL 칸(맨 밑 · 켠 겹 있을 때만 · GL 만) · 등고선 끔 = 등고 글도 숨김
- 626-1 추천 보기 = 도구줄 아이콘 + 아래 판(영선 · 토공 최소 · 기울기 최소 · 비중 계산 · 끔) — route_recommend 저장본(지금 설계 지형) 선만 · 다시 셈 · 쓰기 없음
- 지형 칩 → 확인창 → 새 POST /route/design-terrain(설계 지형만 바꿈 · 노선 저장 체인 다시 · 노선 · 초기값 · 추천 저장본 그대로 · 잠금 · 실패 되돌림)
- 걷음 — 추천 모달(_Recommend · _Help · _Map · CSS) · 좌측 「노선 추천」 칸 · saveRecommendedRoute · UI_RouteReset(서버 as_initial 길 · 시험은 남김)
- 부품 상자 — createPickMenu(아이콘 고르기 메뉴 · 판 = body fixed · ✓)
- 낡은 시험 고침 · 지움 — 모달 · 좌측 칸 · [적용] 화면 배선을 보던 시험(283 · 346_3 · 349 · 364_4 · 383_1 · 390_5 · 418 · 421 · 421_2 · 476_2 · 509_2 · 509_5 · 551_2 · 600_3 · b05_routeedit_initial · design_view_parity · modal_top · 133_1 · 133_2) · test_508_2 · helper_283 지움(모달 전용)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 21:30:49 +09:00

109 lines
4.1 KiB
Python

"""364-4 노선 추천 미리 셈 — B05 열 때 예약 · 겹쳐 셈 막음 · 모달 진행 표시.
./venv/Scripts/python.exe -m pytest resources/tester/test_364_4_precompute_on_open.py -q
옛 프로젝트 · 판이 바뀐 저장본은 사용자가 처음 누를 때 기다렸음(요구 239 · 토공 62.9 s).
`GET /route/plan`(B05 열기)이 미리 셈을 예약 · 도는 동안 또 오면 끝난 뒤 한 번 더 · 진행은
`GET /route/initial/progress` · 모달 상태줄이 그것을 붙임.
"""
import asyncio
from pathlib import Path
from uuid import uuid4
from B05_Profile import B05_Profile_Router_RouteInitial as router
ROOT = Path(__file__).resolve().parents[2]
def test_겹쳐_셈_막음_끝난_뒤_한_번_더(monkeypatch) -> None:
calls: list[str] = []
seen: list[dict] = []
pid = uuid4()
async def precompute(project_id):
calls.append(str(project_id))
progress = router._RUNNING[str(project_id)]
progress.update(total=5, done=2, mode="earthwork")
seen.append(router.precompute_progress(project_id))
await asyncio.sleep(0.05)
monkeypatch.setattr(router, "precompute_defaults", precompute)
async def main() -> None:
first = asyncio.create_task(router.run_precompute(pid))
await asyncio.sleep(0.01)
# 도는 중 두 번 더 와도 셈은 한 번 더만
await router.run_precompute(pid)
await router.run_precompute(pid)
await first
asyncio.run(main())
assert calls == [str(pid), str(pid)]
assert seen[0] == {"running": True, "done": 2, "total": 5, "mode": "earthwork"}
assert router.precompute_progress(pid) == {
"running": False,
"done": 0,
"total": 0,
"mode": None,
}
def test_실패해도_진행_비움(monkeypatch) -> None:
async def broken(_pid):
raise RuntimeError("셈 실패")
monkeypatch.setattr(router, "precompute_defaults", broken)
pid = uuid4()
try:
asyncio.run(router.run_precompute(pid))
except RuntimeError:
pass
assert not router.precompute_progress(pid)["running"]
def test_b05_열기_예약_모달_진행_배선() -> None:
replan = (ROOT / "B05_Profile/B05_Profile_Router_Replan.py").read_text(encoding="utf-8")
plan = replan[replan.index("async def read_route_plan") :]
# 505-1 — B05 열기는 미리 셈 안 부름(전처리 체인에서만)
assert "schedule_precompute(" not in plan[: plan.index("\n@router")]
source = (ROOT / "B05_Profile/B05_Profile_Router_RouteInitial.py").read_text(encoding="utf-8")
assert '"/{project_id}/route/initial/progress"' in source
# 체인 · B01 범위도 같은 한 줄(run_precompute)로
assert "run_precompute(project_id), task_name" in source
assert "await run_precompute(project_id)" in source
api = (ROOT / "B05_Profile/B05_Profile_Api_RouteInitial.ts").read_text(encoding="utf-8")
assert "/route/initial/progress" in api
def test_모달이_여는_갈래_먼저(monkeypatch) -> None:
"""저장된 갈래(추적 아님)를 먼저 셈 — 모달이 열자마자 그 갈래를 물음."""
from B05_Profile.B05_Profile_Engine_RouteInitial_Store import DEFAULT_MODES
asked: list[str] = []
async def paths(_pid):
return (ROOT, None)
async def compute(_pid, request, precompute=False):
assert precompute # 체인 셈 = 저장본 없어도 셈(505-1)
asked.append(request.mode)
assert request.with_profile # 다섯 갈래 모두 종단 켬(420)
return {}
monkeypatch.setattr(router.replan, "_project_paths", paths)
monkeypatch.setattr(
router,
"read_initial_choice",
lambda _root: {"logic": "gentle", "weights": None, "criteria": None},
)
monkeypatch.setattr(router, "compute_initial", compute)
async def terrains(_pid, _root):
return ["las"] # 지형 하나(509-5 지형마다 = test_509_5)
monkeypatch.setattr(router, "precompute_terrains", terrains)
asyncio.run(router.precompute_defaults(uuid4()))
assert asked[0] == "gentle" and asked[-1] == "follow"
assert sorted(asked) == sorted(DEFAULT_MODES)