Livrare LOT 1 - Didi
This commit is contained in:
commit
5380c3fc63
990 changed files with 133308 additions and 0 deletions
51
ai_platform/modules/extractors/tests/test_api.py
Normal file
51
ai_platform/modules/extractors/tests/test_api.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"""End-to-end API tests via FastAPI TestClient."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from PIL import Image
|
||||
|
||||
from extractors.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def _png() -> bytes:
|
||||
buf = io.BytesIO()
|
||||
Image.new("RGB", (40, 40), (200, 10, 10)).save(buf, format="PNG")
|
||||
return buf.getvalue()
|
||||
|
||||
|
||||
def test_health():
|
||||
r = client.get("/health")
|
||||
assert r.status_code == 200
|
||||
assert r.json()["status"] == "ok"
|
||||
|
||||
|
||||
def test_ready_reports_tooling():
|
||||
r = client.get("/ready")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert "ffprobe" in body and "ffmpeg" in body
|
||||
|
||||
|
||||
def test_metadata_image_runs_image_extractors():
|
||||
r = client.post(
|
||||
"/v1/metadata",
|
||||
files={"file": ("photo.png", _png(), "image/png")},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["media_type"] == "image"
|
||||
assert set(body["analyses"]) >= {"integrity", "exif", "ela"}
|
||||
assert len(body["sha256"]) == 64
|
||||
assert body["execution_time_ms"] >= 0
|
||||
|
||||
|
||||
def test_metadata_rejects_empty():
|
||||
r = client.post(
|
||||
"/v1/metadata", files={"file": ("empty.png", b"", "image/png")}
|
||||
)
|
||||
assert r.status_code == 400
|
||||
Loading…
Add table
Add a link
Reference in a new issue