stackchain-dashboard/tests/test_notification_pages.py
timmy a86de5cbf4
All checks were successful
CI / lint (pull_request) Successful in 11s
CI / build-frontend (pull_request) Successful in 5s
feat: paginate unread updates inbox (#147)
2026-08-06 23:30:32 +00:00

34 lines
998 B
Python

import httpx
import pytest
from src import main
@pytest.mark.anyio
async def test_notification_page_endpoint_loads_only_requested_page_and_is_not_cacheable(monkeypatch):
requested = []
async def page_loader(page):
requested.append(page)
return {
"items": [{"id": 51, "title": "Older update"}],
"page": page,
"total": 125,
"has_more": True,
}
monkeypatch.setattr(main.gitea_proxy, "notification_page", page_loader)
transport = httpx.ASGITransport(app=main.app)
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.get("/api/v1/notifications?page=2")
assert response.status_code == 200
assert response.headers["cache-control"] == "no-store"
assert response.json() == {
"items": [{"id": 51, "title": "Older update"}],
"page": 2,
"total": 125,
"has_more": True,
}
assert requested == [2]