From eba6e0c01d56bdad6880a5292a30991f2b865b12 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 26 Oct 2026 08:57:47 +0900 Subject: [PATCH] =?UTF-8?q?fix(B09=20=EC=9D=B8=EC=87=84=20=EB=8F=84?= =?UTF-8?q?=EB=A9=B4):=20=EA=B3=84=ED=9A=8D=ED=8F=89=EB=A9=B4=EB=8F=84=20?= =?UTF-8?q?=ED=8C=8C=EC=83=9D=20=EC=A0=80=EC=9E=A5=EB=B3=B8=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5(Response=20JSON)=EB=8F=84=20=EB=8F=84=EB=A9=B4?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=BD=EC=9D=8C=20=E2=80=94=20=EB=8F=84?= =?UTF-8?q?=EB=A9=B4=20PDF=20400=20=E3=80=8Cplan=5Fterrain=20=EC=9D=84=20?= =?UTF-8?q?=EC=9D=BD=EC=A7=80=20=EB=AA=BB=ED=96=88=EC=8A=B5=EB=8B=88?= =?UTF-8?q?=EB=8B=A4=E3=80=8D=20=ED=95=B4=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 원인: B07 단건 조회가 계획평면도(plan_*)는 파생 저장본(508-3c) 길로 모델 대신 날 JSON Response 를 돌려줌 · B09 는 .drawing 속성만 보고 오류로 침 - 고침: 200 · application/json Response 면 본문 JSON 을 그대로 읽음 · 오류 응답은 그대로 400 글 - 지킴 시험 test_543_print_plan_stored_copy (저장본 Response 읽음 · 오류 응답 읽지 못함) Co-Authored-By: Claude Opus 5.5 --- .../draft/B09_Draft_Print_Drawings_Source.py | 10 ++++-- .../tester/test_543_print_plan_stored_copy.py | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 resources/tester/test_543_print_plan_stored_copy.py diff --git a/B09_Estimation/draft/B09_Draft_Print_Drawings_Source.py b/B09_Estimation/draft/B09_Draft_Print_Drawings_Source.py index b3bc11872..2d05d08b7 100644 --- a/B09_Estimation/draft/B09_Draft_Print_Drawings_Source.py +++ b/B09_Estimation/draft/B09_Draft_Print_Drawings_Source.py @@ -11,6 +11,7 @@ B07 화면과 같은 TS 를 Node 로(`B09_Draft_Print_Drawings_Node.ts` · CLAUD from __future__ import annotations import asyncio +import json import logging import subprocess from pathlib import Path @@ -76,9 +77,12 @@ async def b07_drawing(project_id: UUID, drawing_id: str) -> dict[str, Any]: from B07_DesignDetail.B07_DesignDetail_Router import get_design_drawing response = await get_design_drawing(project_id, drawing_id) - if not hasattr(response, "drawing"): - raise ValueError(f"B07 도면 「{drawing_id}」 을 읽지 못했습니다.") - return response.model_dump() + if hasattr(response, "drawing"): + return response.model_dump() + # 계획평면도 파생 저장본(508-3c) = 그린 응답 JSON 그대로(Response) — 오류 JSONResponse 와 구별 + if getattr(response, "status_code", None) == 200 and response.media_type == "application/json": + return json.loads(response.body) + raise ValueError(f"B07 도면 「{drawing_id}」 을 읽지 못했습니다.") async def section_detail(project_id: UUID, route_id: int) -> dict[str, Any] | None: diff --git a/resources/tester/test_543_print_plan_stored_copy.py b/resources/tester/test_543_print_plan_stored_copy.py new file mode 100644 index 000000000..c9a4d02ea --- /dev/null +++ b/resources/tester/test_543_print_plan_stored_copy.py @@ -0,0 +1,35 @@ +"""B09 인쇄 도면 — B07 계획평면도 파생 저장본(Response JSON 그대로)도 읽음 · 오류 응답은 400 글.""" + +from __future__ import annotations + +import asyncio +import json +from uuid import uuid4 + +import pytest +from fastapi import Response +from fastapi.responses import JSONResponse + +from B07_DesignDetail import B07_DesignDetail_Router as b07 +from B09_Estimation.draft import B09_Draft_Print_Drawings_Source as source + +DRAWING = {"entities": [{"type": "Line"}], "layers": []} + + +def _read(monkeypatch, response): + async def fake(project_id, drawing_id): + return response + + monkeypatch.setattr(b07, "get_design_drawing", fake) + return asyncio.run(source.b07_drawing(uuid4(), "plan_terrain")) + + +def test_저장본_Response_JSON_을_읽음(monkeypatch): + body = json.dumps({"id": "plan_terrain", "drawing": DRAWING, "confirmed": False}) + got = _read(monkeypatch, Response(content=body.encode(), media_type="application/json")) + assert got["drawing"] == DRAWING and got["confirmed"] is False + + +def test_오류_응답은_읽지_못함(monkeypatch): + with pytest.raises(ValueError, match="plan_terrain"): + _read(monkeypatch, JSONResponse(status_code=404, content={"message": "없음"}))