Files
Aislo/resources/tester/test_530_2_plan_router.py
T
eomsangdonandClaude Opus 5.5 f76c31b063 Merge origin/dev into sub_laptop_1 — 560-2 전체 시점 · 종점 · 562-2 노선 정본 받기 (PLAN 561-2)
- 충돌 셋 풂: D03 라우터(562-2 가 분석 API 걷음 + 561-2 지형 한 벌 · 범위 API) · 시험 530_2_plan_router 다시 씀 · 530_2_plan_analyze = dev 판
- 지형 범위의 전체 시점 · 종점 = D02 정본 load_base(plan_base_json · 빈 칸이면 옛 연도 행 접음) — 임시 _plan_inputs 감쌈 걷음
- Terrain — 옛 분석이 쓰던 연도 인자 · 복도 상수 걷음(분석 엔진 걷힘)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:16:04 +09:00

99 lines
3.5 KiB
Python

"""D 지형 API(PLAN 530-1 · 561-2) — 범위 = 전체 시점 · 종점(D02 정본) 상자 + 여유 · 받기 = 한 벌.
옛 분석 API 시험(GET · PUT analysis · 꺾임점 고침)은 옛 추천 엔진과 함께 걷음(PLAN 562-2) ·
노선 정본 시험 = `test_530_2_plan_analyze.py` · 지형 셈 시험 = `test_530_1_plan_terrain.py`.
./venv/Scripts/python.exe -m pytest resources/tester/test_530_2_plan_router.py -q
"""
import asyncio
import json
from contextlib import asynccontextmanager
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from D03_PlanAnalysis import D03_PlanAnalysis_Router as router_mod
PID = "12953f5a-5ba1-42ad-a427-8ac857a58bc2"
P0, P2 = (0.0, 0.0), (900.0, 400.0)
URL = f"/api/projects/{PID}/plan/terrain"
class _Pool:
@asynccontextmanager
async def acquire(self):
yield None
@pytest.fixture
def client(tmp_path, monkeypatch):
plan = {
"epsg": 5186,
"start": {"lon": 0, "lat": 0, "x": P0[0], "y": P0[1]},
"end": {"lon": 0, "lat": 0, "x": P2[0], "y": P2[1]},
}
async def load_base(project_id):
return plan
async def stored(connection, project_id):
return "1/3/p"
monkeypatch.setattr(router_mod.base, "load_base", load_base)
monkeypatch.setattr(router_mod, "get_db_pool", lambda: _Pool())
monkeypatch.setattr(router_mod, "get_project_storage_relative_path", stored)
monkeypatch.setattr(router_mod, "resolve_stored_project_path", lambda s: str(tmp_path))
app = FastAPI()
app.include_router(router_mod.router)
test = TestClient(app)
test.plan = plan
return test
def test_extent_uses_whole_ends(client) -> None:
got = client.get(f"{URL}/extent?margin_m=400").json()
m = 400.0
assert got["margin_m"] == m and got["have"] is None and got["covered"] is False
# 전체 시점 · 종점(D02 정본) — 연도 구간 아님
assert got["box_m"] == [P0[0] - m, P0[1] - m, P2[0] + m, P2[1] + m]
extra = client.get(f"{URL}/extent", params={"extra": json.dumps([[2000, 0]])}).json()
assert extra["box_m"][2] == 2000 + extra["margin_m"]
assert client.get(f"{URL}/extent", params={"extra": "[1]"}).status_code == 400
client.plan["end"] = None # 종점 빔 — 1단계로
assert client.get(f"{URL}/extent").status_code == 400
def test_post_runs_one_set(client, monkeypatch) -> None:
calls: list = []
saved: list = []
works: list = []
def ensure(root, points, epsg, margin_m, report):
calls.append((points, epsg, margin_m))
return {"sheets": {"downloaded": ["1"]}, "models": [{"model_file_path": "m"}]}
async def save(project_id, models, epsg):
saved.append((models, epsg))
def start(project_id, kind, work):
works.append(work)
return {"status": "accepted", "kind": kind}
def post(body):
res = client.post(URL, json=body)
asyncio.run(works.pop()(lambda percent, message: None))
return res
monkeypatch.setattr(router_mod.terrain, "ensure_plan_terrain", ensure)
monkeypatch.setattr(router_mod, "_save_models", save)
monkeypatch.setattr(router_mod, "_start_job", start)
res = post({"margin_m": 500, "extra": [[5, 6]]})
assert res.json() == {"status": "accepted", "kind": "terrain"}
assert calls == [([P0, P2, (5.0, 6.0)], 5186, 500.0)]
assert saved == [([{"model_file_path": "m"}], 5186)]
# 옛 화면 꼴(points 몸) — 여유 처음 값 · 전체 시점 · 종점
post({"points": []})
assert calls[-1] == ([P0, P2], 5186, None)