Files
SPipe/backend/tests/test_drawing_dxf.py
SPipe EngineeringandClaude Opus 5.5 e3f386addf 도면 출력 추가: 수리 종단면도, 관망도(색인도·부분도·수압표), 범례·색상 선택, DXF(AutoCAD 2018)
- 데모 v2 이후 개발 PC의 변경을 옮김 (이 저장소의 이름 변경·README 정리는 유지)
- 서버 기본 DEM, DEM 등고선, 속성 테이블 범위 선택, WNTR 교차 검증 시험 포함
- 새 라이브러리: ezdxf(Python), maplibre-contour(npm)
- 변경 내역: docs/SPipe_패치내역_도면출력_2026-11-06.txt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 15:03:21 +09:00

36 lines
1.4 KiB
Python

"""/api/drawing/dxf: browser R12 DXF (Unicode escapes) -> Korean code page (ANSI_949)."""
import os
import tempfile
import pyogrio
from fastapi.testclient import TestClient
from backend.main import app, dxf_to_cp949
DXF = "\r\n".join([
"0", "SECTION", "2", "HEADER", "9", "$ACADVER", "1", "AC1009", "0", "ENDSEC",
"0", "SECTION", "2", "ENTITIES",
"0", "TEXT", "8", "TITLE", "10", "1", "20", "2", "30", "0", "40", "2.5", "1", r"\U+C218\U+B9AC \U+C885\U+B2E8\U+BA74\U+B3C4 \U+1F600",
"0", "ENDSEC", "0", "EOF", "",
])
def test_conversion_reads_back_as_korean():
data = dxf_to_cp949(DXF)
assert b"$DWGCODEPAGE\r\n3\r\nANSI_949" in data
with tempfile.TemporaryDirectory() as tmp:
p = os.path.join(tmp, "t.dxf")
open(p, "wb").write(data)
meta, _, _, fields = pyogrio.raw.read(p)
text = fields[list(meta["fields"]).index("Text")][0]
assert text.startswith("수리 종단면도")
assert r"\U+1F600" in data.decode("cp949") # outside CP949: kept escaped
def test_endpoint():
with TestClient(app) as c:
r = c.post("/api/drawing/dxf", json={"dxf": DXF, "name": "수리 종단면도"})
assert r.status_code == 200 and "attachment" in r.headers["content-disposition"]
assert "수리".encode("cp949") in r.content
assert c.post("/api/drawing/dxf", json={"dxf": "nope"}).status_code == 400