| """Integration test script — run when FAISS store and models are available. |
| |
| Usage: |
| cd backend |
| python scripts/integration_test.py |
| """ |
|
|
| import sys |
| from pathlib import Path |
|
|
| sys.path.insert(0, str(Path(__file__).parent.parent)) |
|
|
|
|
| def test_health(): |
| import httpx |
|
|
| try: |
| r = httpx.get("http://localhost:8000/health", timeout=5) |
| assert r.status_code == 200 |
| print("[OK] Backend health check") |
| except Exception as e: |
| print(f"[SKIP] Backend not running: {e}") |
|
|
|
|
| def test_faiss(): |
| from db.faiss_client import FaissDB |
|
|
| db = FaissDB() |
| db.list_documents() |
| print("[OK] FAISS store ready") |
| db.close() |
|
|
|
|
| def test_embedder(): |
| print("Embedder runs on Modal — run: python scripts/test_embedder.py") |
|
|
|
|
| def main(): |
| print("FinSight AI Integration Tests") |
| print("=" * 40) |
| try: |
| test_faiss() |
| except Exception as e: |
| print(f"[FAIL] FAISS: {e}") |
| return 1 |
|
|
| try: |
| test_embedder() |
| except Exception as e: |
| print(f"[SKIP] Embedder (Modal): {e}") |
| print(" -> Deploy with: modal deploy finsight_modal/app.py") |
|
|
| test_health() |
| print("=" * 40) |
| print("Core integration tests passed.") |
| return 0 |
|
|
|
|
| if __name__ == "__main__": |
| sys.exit(main()) |
|
|