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"]