File size: 753 Bytes
b25b8f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_health_check():
"""Test the health endpoint."""
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "healthy", "service": "preprocessing"}
def test_preprocess_text():
"""Test the text preprocessing and tokenization logic."""
payload = {"text": "2 x 4 + y = 10", "source": "ocr"}
response = client.post("/preprocess", json=payload)
assert response.status_code == 200
data = response.json()
assert data["normalized_text"] == "2 * 4 + y = 10"
assert "tokens" in data
assert data["tokens"] == ["2", "*", "4", "+", "y", "=", "10"]
|