Spaces:
Running
Running
| import os | |
| os.environ["SUPABASE_URL"] = "http://localhost" | |
| os.environ["SUPABASE_ANON_KEY"] = "fake" | |
| os.environ["SUPABASE_DB_URL"] = "postgres://fake" | |
| import pytest | |
| from unittest.mock import patch | |
| from fastapi.testclient import TestClient | |
| from api import app | |
| client = TestClient(app) | |
| def test_scan_async_endpoint(mock_run_bg, mock_create_scan_job): | |
| # Attempt to hit the new async endpoint | |
| response = client.post("/api/scan/async", json={ | |
| "connector_type": "postgres", | |
| "host": "localhost", | |
| "port": "5432", | |
| "database": "mydb", | |
| "user": "user", | |
| "password": "pass", | |
| "table": "users" | |
| }) | |
| # Should return 202 Accepted and a job_id | |
| assert response.status_code == 202 | |
| data = response.json() | |
| assert "job_id" in data | |
| assert data["status"] == "queued" | |
| def test_scan_status_endpoint(): | |
| response = client.get("/api/scan/status/123e4567-e89b-12d3-a456-426614174000") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "job_id" in data | |
| assert "status" in data | |
| def test_catalog_endpoint(): | |
| response = client.get("/api/catalog/mydb") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert isinstance(data, list) | |