FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
|
|
def _register_and_login(client) -> dict[str, str]:
|
|
email = f"user-{uuid.uuid4().hex[:12]}@example.com"
|
|
client.post(
|
|
"/api/v1/auth/register",
|
|
json={"email": email, "password": "correct-horse-1", "display_name": "Test User"},
|
|
)
|
|
tokens = client.post(
|
|
"/api/v1/auth/login", json={"email": email, "password": "correct-horse-1"}
|
|
).json()
|
|
return {"Authorization": f"Bearer {tokens['access_token']}"}
|
|
|
|
|
|
def test_dashboard_analytics_returns_zero_filled_buckets_for_a_new_user(client):
|
|
headers = _register_and_login(client)
|
|
|
|
resp = client.get("/api/v1/dashboard/analytics", headers=headers)
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert set(body["changes_by_type"].keys()) == {
|
|
"new_document",
|
|
"removed_document",
|
|
"content_modified",
|
|
"price_change",
|
|
"leadership_change",
|
|
"filing_new",
|
|
}
|
|
assert all(v == 0 for v in body["changes_by_type"].values())
|
|
assert body["recent_signals"] == []
|
|
|
|
|
|
def test_dashboard_analytics_requires_auth(client):
|
|
resp = client.get("/api/v1/dashboard/analytics")
|
|
assert resp.status_code in (401, 403)
|