Spaces:
Paused
Paused
File size: 1,123 Bytes
211e423 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
"""Tests for the main FastAPI application."""
import pytest
from fastapi.testclient import TestClient
from src.kybtech_dots_ocr.app import app
client = TestClient(app)
def test_health_check():
"""Test the health check endpoint."""
response = client.get("/health")
assert response.status_code == 200
data = response.json()
assert "status" in data
assert "version" in data
def test_ocr_endpoint_missing_file():
"""Test OCR endpoint with missing file."""
response = client.post("/v1/id/ocr")
assert response.status_code == 422 # Validation error
def test_ocr_endpoint_invalid_file():
"""Test OCR endpoint with invalid file."""
files = {"file": ("test.txt", b"not an image", "text/plain")}
response = client.post("/v1/id/ocr", files=files)
# Should handle gracefully
assert response.status_code in [400, 422, 500]
@pytest.mark.skip(reason="Requires model to be loaded")
def test_ocr_endpoint_with_image():
"""Test OCR endpoint with actual image (requires model)."""
# This test would require the model to be loaded
# and actual image data
pass
|