Spaces:
Sleeping

studiq-backend / tests /test_layer5.py
StudIQ Deploy Bot
Deploy StudIQ v0.5.1 — 2026-08-09 14:39 UTC
0fa6c62
Raw History Blame Contribute Delete
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
@pytest.mark.asyncio
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"]
@pytest.mark.asyncio
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