Initial commit: 包装审核 POC、Docker 与前后端
Made-with: Cursor
This commit is contained in:
31
tests/backend/test_ai_render_crop_api.py
Normal file
31
tests/backend/test_ai_render_crop_api.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from backend.app.main import app
|
||||
|
||||
|
||||
WORKDIR = Path("/Users/icemilk/Workspace/zld_POC")
|
||||
AI_FILE = WORKDIR / "【2026-04-09】端午 - 背标 - 天问.ai"
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_ai_render_crop_endpoint_returns_two_images_and_crop_box() -> None:
|
||||
with AI_FILE.open("rb") as ai_fp:
|
||||
response = client.post(
|
||||
"/api/ai-render-crop",
|
||||
files={
|
||||
"ai_file": (AI_FILE.name, ai_fp, "application/postscript"),
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
payload = response.json()
|
||||
assert payload["fullImage"]["type"] == "image"
|
||||
assert payload["croppedImage"]["type"] == "image"
|
||||
assert payload["fullImage"]["url"].endswith(".png")
|
||||
assert payload["croppedImage"]["url"].endswith(".png")
|
||||
assert payload["cropBox"]["x1"] > payload["cropBox"]["x0"]
|
||||
assert payload["cropBox"]["y1"] > payload["cropBox"]["y0"]
|
||||
Reference in New Issue
Block a user