""" Test cases for PDF Redaction API """ import pytest from fastapi.testclient import TestClient from pathlib import Path import sys # Add parent directory to path sys.path.insert(0, str(Path(__file__).parent.parent)) from main import app client = TestClient(app) def test_health_check(): """Test health check endpoint""" response = client.get("/health") assert response.status_code == 200 data = response.json() assert data["status"] == "healthy" assert "model_loaded" in data def test_root(): """Test root endpoint""" response = client.get("/") assert response.status_code == 200 data = response.json() assert data["status"] == "healthy" def test_stats(): """Test stats endpoint""" response = client.get("/stats") assert response.status_code == 200 data = response.json() assert "pending_uploads" in data assert "processed_files" in data assert "model_loaded" in data def test_redact_no_file(): """Test redaction without file""" response = client.post("/redact") assert response.status_code == 422 # Unprocessable entity def test_redact_wrong_file_type(): """Test redaction with wrong file type""" files = {"file": ("test.txt", b"test content", "text/plain")} response = client.post("/redact", files=files) assert response.status_code == 400 def test_download_nonexistent(): """Test downloading non-existent file""" response = client.get("/download/nonexistent-id") assert response.status_code == 404 # Add more tests as needed # - Test with actual PDF file # - Test with different DPI values # - Test with entity type filtering # - Test cleanup functionality