Some checks failed
Deploy to Staging / Build Images (pull_request) Failing after 4m14s
Deploy to Staging / Deploy to Staging (pull_request) Has been skipped
Deploy to Staging / Verify Staging (pull_request) Has been skipped
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 8s
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""Tests for OCR service health and core functionality."""
|
|
import io
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
from PIL import Image
|
|
|
|
from app.main import app
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
"""Create test client for FastAPI app."""
|
|
return TestClient(app)
|
|
|
|
|
|
def test_health_endpoint(client):
|
|
"""Health endpoint returns healthy status."""
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"status": "healthy"}
|
|
|
|
|
|
def test_root_endpoint(client):
|
|
"""Root endpoint returns service information."""
|
|
response = client.get("/")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["service"] == "mvp-ocr"
|
|
assert "version" in data
|
|
|
|
|
|
def test_pillow_heif_can_register():
|
|
"""pillow-heif can register with Pillow for HEIC support."""
|
|
import pillow_heif
|
|
|
|
pillow_heif.register_heif_opener()
|
|
# Verify HEIC format is registered
|
|
assert "HEIF" in Image.registered_extensions().values()
|
|
|
|
|
|
def test_paddleocr_engine_available():
|
|
"""PaddleOCR engine can be created."""
|
|
from app.engines.paddle_engine import PaddleOcrEngine
|
|
|
|
engine = PaddleOcrEngine()
|
|
assert engine.name == "paddleocr"
|