fix(B09 인쇄 도면): 계획평면도 파생 저장본 응답(Response JSON)도 도면으로 읽음 — 도면 PDF 400 「plan_terrain 을 읽지 못했습니다」 해소
- 원인: 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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": "없음"}))
|
||||
Reference in New Issue
Block a user