- (B) 종단도 기준(기울기 상한 · 최소고 강제 · 시작 측점) = 세션 초안 ?? 저장 노선 설정 — 두 보기가 그린 뒤 applyPageSettings 하나 · B06 이 받은 노선은 캐시에 - (C) 상세 강제 다시 받기 = 듣는 쪽 한 번(숨은 종단 보기 옛 객체 안 쥠) · [측점 만들기] 뒤 캐시 비우고 강제로 받음 - (D) [저장] 상단측 차례 = flushRouteParts 한 벌(노선 캐시 지표 조건 + 확정 지표면 id · 비정규 빈 목록) — 종단 보기를 열든 안 열든 같은 요청 - 시험 test_271_detail_notify · test_271_save_same · test_271_profile_settings · 옛 저장 시험 가짜 창구에 flushRouteParts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.2 KiB
Python
85 lines
3.2 KiB
Python
"""463 B05 · B06 한 페이지 — [저장] 같은 본문(요구 271-5 · 분석 4장 (D)).
|
|
|
|
① 종단 보기를 안 연 [저장](기본 창구) · 연 뒤 [저장](종단 보기 몫) = 요청 줄 같음
|
|
— 옛 코드 = 기본 창구가 상단측만 보내 서버 확정 요청에 지표 조건 · 확정 지표면 id 가 빠짐
|
|
(비정규 측점 횡단 맞춤 안 돎)
|
|
② 노선 캐시 없음(새로고침해 B06 로 바로) = 서버에서 한 번 읽고 같은 본문
|
|
③ 서버 — 그 본문이면 확정이 비정규 측점 횡단을 맞춤(`can_regenerate`)
|
|
TS 셈은 `helper_271_save_same.cjs`.
|
|
|
|
./venv/Scripts/python.exe -m pytest resources/tester/test_271_save_same.py -q
|
|
"""
|
|
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from B05_Profile.B05_Profile_Schema import RouteConfirmRequest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
HELPER = Path(__file__).with_name("helper_271_save_same.cjs")
|
|
|
|
pytestmark = pytest.mark.skipif(
|
|
not (ROOT / "config" / "node_modules" / "typescript").is_dir(),
|
|
reason="프론트엔드 의존성 미설치",
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def got() -> dict:
|
|
run = subprocess.run( # noqa: S603 — 고정 실행 파일
|
|
["node", str(HELPER)],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=120,
|
|
)
|
|
assert run.returncode == 0, run.stderr
|
|
return json.loads(run.stdout)
|
|
|
|
|
|
def _confirm_body(lines: list[str]) -> dict:
|
|
posts = [line for line in lines if line.startswith("POST ") and "/route/confirm" in line]
|
|
assert len(posts) == 1, lines
|
|
return json.loads(posts[0].split(" ", 2)[2])
|
|
|
|
|
|
def test_종단_보기를_열든_안_열든_같은_요청(got):
|
|
assert got["closed"]["ok"] and got["open"]["ok"]
|
|
assert got["closed"]["failed"] == [] and got["open"]["failed"] == []
|
|
assert got["closed"]["lines"] == got["open"]["lines"]
|
|
body = _confirm_body(got["closed"]["lines"])
|
|
assert body == {
|
|
"filter_key": "csf",
|
|
"method": "tin",
|
|
"smooth": True,
|
|
"surface_model_id": 7,
|
|
"irregular_stations": [],
|
|
"uphill_overrides": [{"chainage_m": 40, "side": "right"}],
|
|
}
|
|
# 상단측 세션 · 종단 보기 메모리 둘 다 비움(다음 [저장]이 옛 값을 다시 안 보냄)
|
|
assert got["closed"]["uphillAfter"] is None and got["open"]["uphillAfter"] is None
|
|
assert got["openMemoryAfter"] == 0
|
|
|
|
|
|
def test_노선_캐시_없어도_같은_본문(got):
|
|
lines = got["noCache"]["lines"]
|
|
assert lines[0] == "GET /api/projects/P463/route/latest"
|
|
assert _confirm_body(lines) == _confirm_body(got["closed"]["lines"])
|
|
|
|
|
|
def test_서버는_그_본문이면_비정규_측점_횡단을_맞춤(got):
|
|
body = _confirm_body(got["closed"]["lines"])
|
|
assert RouteConfirmRequest(**body).can_regenerate()
|
|
assert not RouteConfirmRequest(uphill_overrides=body["uphill_overrides"]).can_regenerate()
|
|
|
|
|
|
def test_종단_보기_몫은_기본_창구_함수를_부름():
|
|
actions = (ROOT / "B05_Profile" / "B05_Profile_UI_Page_Actions.ts").read_text("utf-8")
|
|
save = (ROOT / "A00_Common" / "design" / "design_save.ts").read_text("utf-8")
|
|
assert "await flushRouteParts(projectId);" in actions
|
|
assert "saveRouteParts(" not in actions
|
|
assert "return () => flushRouteParts(projectId);" in save
|