Spaces:
Sleeping
Sleeping
Download tests/test_layer5.py from baljot07/studiq-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/baljot07/studiq-backend/resolve/main/tests/test_layer5.py
- Command line
-
hf download hf://spaces/baljot07/studiq-backend/tests/test_layer5.py
-
curl -L -o test_layer5.py https://huggingface.co/spaces/baljot07/studiq-backend/resolve/main/tests/test_layer5.py
1.28 kB
| """Tests for Layer 5 - health check and error reporting endpoints.""" | |
| import pytest | |
| from httpx import AsyncClient | |
| from tests.test_profile import get_auth_headers | |
| async def test_health_check_endpoint(client: AsyncClient): | |
| """Test health check queries DB and Redis.""" | |
| response = await client.get("/api/v1/health") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["status"] in ("ok", "degraded") | |
| assert "version" in data | |
| assert "checks" in data | |
| assert "database" in data["checks"] | |
| assert "redis" in data["checks"] | |
| async def test_error_report_endpoint(client: AsyncClient, allow_rate_limit): | |
| """Test POST /errors/report receives client-side error report.""" | |
| headers = await get_auth_headers(client) | |
| report_data = { | |
| "screen": "viva_screen", | |
| "error": "NullPointerReferenceException: something was null", | |
| "context": "viva start error", | |
| "platform": "flutter", | |
| "timestamp": "2026-05-28T21:50:00Z" | |
| } | |
| response = await client.post( | |
| "/api/v1/errors/report", | |
| json=report_data, | |
| headers=headers | |
| ) | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["received"] is True | |