fix: bound event stream refresh latency (#58)
CI / lint (pull_request) Successful in 8s
CI / build-frontend (pull_request) Successful in 4s

This commit is contained in:
timmy committed 2026-08-06 01:18:41 +00:00
1 parent 609df470d6
commit a173182158
2 files changed
+46 -2

No files matched your search

+25
View File
@@ -1,3 +1,5 @@
import asyncio
import json
from pathlib import Path
import pytest
@@ -49,6 +51,29 @@ async def test_event_stream_returns_recent_authenticated_gitea_activity(monkeypa
assert response == expected
@pytest.mark.anyio
async def test_event_stream_returns_retryable_response_when_gitea_exceeds_deadline(monkeypatch):
cancelled = asyncio.Event()
async def hanging_activity_events():
try:
await asyncio.Event().wait()
finally:
cancelled.set()
monkeypatch.setattr(main, "EVENT_STREAM_TIMEOUT_SECONDS", 0.01)
monkeypatch.setattr(main, "activity_events", hanging_activity_events)
response = await main.event_stream()
assert response.status_code == 503
assert response.headers["retry-after"] == "1"
assert json.loads(response.body) == {
"error": "Gitea event stream request timed out after 0.01s"
}
assert cancelled.is_set()
@pytest.mark.anyio
async def test_activity_events_fetches_feed_for_authenticated_user(monkeypatch):
paths = []