Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /GRID-INTELLIGENCE_GRID /tests /integration /test_api.py
| from typing import Generator | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| try: | |
| from grid.api.main import app | |
| except Exception: | |
| pytest.skip("grid.api.main requires database backend (psycopg2)", allow_module_level=True) | |
| def client() -> Generator[TestClient]: | |
| """Test client fixture""" | |
| yield TestClient(app) | |
| def auth_client(client: TestClient) -> TestClient: | |
| """Client with authentication token""" | |
| # Get auth token | |
| response = client.post("/auth/token", data={"username": "testuser", "password": "testpass"}) | |
| if response.status_code == 200: | |
| token = response.json()["access_token"] | |
| headers = {"Authorization": f"Bearer {token}"} | |
| return TestClient(app, headers=headers) | |
| else: | |
| # Log the failure for debugging | |
| print(f"Auth failed with status {response.status_code}: {response.text}") | |
| # If auth fails, return client without auth (for testing endpoints that don't require auth) | |
| return client | |
| def test_health_check(client: TestClient) -> None: | |
| response = client.get("/health") | |
| assert response.status_code == 200 | |
| assert response.json() == {"status": "healthy", "version": "1.0.0"} | |
| def test_root_endpoint(client: TestClient) -> None: | |
| response = client.get("/") | |
| assert response.status_code == 200 | |
| assert "GRID API" in response.json()["message"] | |
| def test_inference_endpoint(auth_client: TestClient) -> None: | |
| response = auth_client.post("/api/v1/inference/", json={"prompt": "Test prompt", "model": "default"}) | |
| assert response.status_code == 200 | |
| assert "result" in response.json() | |
| def test_privacy_detection(auth_client: TestClient) -> None: | |
| response = auth_client.post("/api/v1/privacy/detect", json={"text": "Contact me at test@example.com"}) | |
| assert response.status_code == 200 | |
| assert len(response.json()["detected_entities"]) > 0 | |
Xet Storage Details
- Size:
- 1.91 kB
- Xet hash:
- 0467cbee0d4b2e236a7ed5a7a07476ea609d96ecf2bd6d178b181ab227211b3c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.