"""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": "없음"}))