From 83e85ed13b6b792ba26bcc3a5b51e6dcca8589bd Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 19 Oct 2026 15:42:09 +0900 Subject: [PATCH] =?UTF-8?q?test(472-6=20=EC=A0=80=EC=9E=A5=20=EC=8B=9C?= =?UTF-8?q?=ED=97=98):=20=ED=95=9C=20=EB=B3=B8=EB=AC=B8=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EC=8B=9C=ED=97=98=EC=9D=B4=20=EB=B0=95=EC=9D=80=20?= =?UTF-8?q?=EB=85=B8=EC=84=A0=20380=20=EB=8C=80=EC=8B=A0=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=5Fsub8=20=EC=B5=9C=EC=8B=A0=20=EB=85=B8=EC=84=A0=20?= =?UTF-8?q?=C2=B7=20=EC=B6=94=EA=B0=80=20=EC=B8=A1=EC=A0=90=20=EC=9E=90?= =?UTF-8?q?=EB=A6=AC=EB=A5=BC=20=EA=B7=B8=EB=95=8C=20=EC=9D=BD=EC=9D=8C=20?= =?UTF-8?q?=E2=80=94=20=EB=85=B8=EC=84=A0=20=EB=B0=94=EB=80=8C=EC=96=B4?= =?UTF-8?q?=EB=8F=84=20=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 최신 노선 id = 저장 창구가 견주는 workflow 노선 · 추가 측점 = 가운데 두 측점 사이 - 옛 차례 대 한 본문 비교에서 행 자동 번호(id) 뺌 — 새 추가 측점 행은 두 길이 다른 번호를 받음 Co-Authored-By: Claude Opus 5.5 --- resources/tester/test_472_6_design_save.py | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/resources/tester/test_472_6_design_save.py b/resources/tester/test_472_6_design_save.py index 5f1af1c1f..d2d444d9f 100644 --- a/resources/tester/test_472_6_design_save.py +++ b/resources/tester/test_472_6_design_save.py @@ -4,6 +4,7 @@ ② 실제 창구(검증_sub8 · DB · storage) — 중간 차례 실패 → DB 7 표 행 · storage 해시 시작 그대로 · 차례 이름 · 까닭 · restored. 같은 본문 정상 = 옛 차례(안쪽 창구 차례로 부름)와 행 · 파일 같음. 검증 프로젝트가 없는 자리(다른 PC · DB 없음)는 ② 건너뜀. +② 는 살아 있는 검증_sub8 사용 · 노선 바뀌어도 됨(최신 노선 id · 추가 측점 자리를 그때 읽음). ./venv/Scripts/python.exe -m pytest resources/tester/test_472_6_design_save.py -q """ @@ -106,13 +107,46 @@ def _state(root: Path) -> tuple[dict, dict]: return clean, files +def _latest_route() -> tuple[int, float]: + """(최신 노선 id — 저장 창구가 견주는 그 값, 추가 측점 자리 — 가운데 두 측점 사이).""" + from B06_Section.B06_Section_Repository import get_workflow_route_context + from config.config_db import close_db_pool, init_db_pool + + async def run(): + pool = await init_db_pool() + try: + async with pool.acquire() as connection: + return await get_workflow_route_context(connection, UUID(PROJECT)) + finally: + await close_db_pool() + + route_id = int(asyncio.run(run())["route_id"]) + longitudinal = ROOT_DIR / "B06_Section" / "longitudinal" / "longitudinal.json" + stations = json.loads(longitudinal.read_text(encoding="utf-8"))["stations"] + middle = len(stations) // 2 + a, b = (float(stations[i]["chainage_m"]) for i in (middle - 1, middle)) + return route_id, round((a + b) / 2, 2) + + +def _without_ids(rows: dict) -> dict: + """행 자동 번호(`id`) 뺀 비교 꼴 — 새 추가 측점 행은 두 길이 다른 번호를 받음.""" + return { + table: sorted( + json.dumps({k: v for k, v in row.items() if k != "id"}, sort_keys=True) + for row in values + ) + for table, values in rows.items() + } + + def _request(**extra): from B06_Section.B06_Section_Router_DesignSave import DesignSaveRequest + route_id, plus_at = _latest_route() body = { - "route_id": 380, + "route_id": route_id, "settings": {"design_speed_kph": 20, "terrain_type": "special", "max_grade_pct": 13.0}, - "plus_stations": {"chainages": [500.0]}, + "plus_stations": {"chainages": [plus_at]}, "cross": {}, **extra, } @@ -171,7 +205,7 @@ def test_정상_한_본문은_옛_차례와_같음() -> None: files = guard.snapshot_storage(ROOT_DIR, guard.STORAGE_SCOPE) await save_page_settings(UUID(PROJECT), request.settings) await put_plus_stations(UUID(PROJECT), request.plus_stations) - await save_sections(UUID(PROJECT), 380, request.cross) + await save_sections(UUID(PROJECT), request.route_id, request.cross) return rows, files finally: await close_db_pool() @@ -195,7 +229,7 @@ def test_정상_한_본문은_옛_차례와_같음() -> None: assert status == 200 and body["status"] == "success", body assert set(body["steps"]) == {"settings", "plusStations", "cross"} new = _state(ROOT_DIR) - assert new[0] == old[0] + assert _without_ids(new[0]) == _without_ids(old[0]) assert new[1] == old[1] finally: asyncio.run(undo()) @@ -225,13 +259,15 @@ def test_같은_프로젝트_저장이_겹치면_뒤_요청이_기다림() -> No from B06_Section.B06_Section_Router_DesignSave import DesignSaveRequest, save_design from config.config_db import close_db_pool, init_db_pool + route_id = _latest_route()[0] + async def run(): await init_db_pool() try: lock = guard.project_lock(PROJECT) await lock.acquire() task = asyncio.create_task( - save_design(UUID(PROJECT), DesignSaveRequest(route_id=380), None) + save_design(UUID(PROJECT), DesignSaveRequest(route_id=route_id), None) ) await asyncio.sleep(0.3) assert not task.done() # 앞 저장(잠금)이 끝날 때까지 기다림