test: restore cache-policy suite setup (Closes #1473)
All checks were successful
CI / lint (pull_request) Successful in 3m43s
CI / build-release (pull_request) Successful in 6s
CI / release-candidate (pull_request) Has been skipped
CI / browser-journey (pull_request) Successful in 7m33s

This commit is contained in:
timmy 2026-08-27 16:16:52 +00:00
parent 0e70fb9b62
commit 454e2dcffc

View File

@ -6,6 +6,8 @@ from src import main
@pytest.mark.anyio @pytest.mark.anyio
async def test_live_gitea_api_responses_cannot_be_stored_by_shared_caches(monkeypatch): async def test_live_gitea_api_responses_cannot_be_stored_by_shared_caches(monkeypatch):
monkeypatch.setenv("STACKCHAIN_DASHBOARD_AUTH_MODE", "insecure-local")
async def user(): async def user():
return {"id": 1, "login": "timmy"} return {"id": 1, "login": "timmy"}
@ -15,13 +17,17 @@ async def test_live_gitea_api_responses_cannot_be_stored_by_shared_caches(monkey
async def empty_events(user_data=None): async def empty_events(user_data=None):
return [] return []
async def empty_live_snapshot(**_revisions):
return main.JSONResponse({})
monkeypatch.setattr(main, "current_user", user) monkeypatch.setattr(main, "current_user", user)
monkeypatch.setattr(main, "repos", empty_collection) monkeypatch.setattr(main, "repos", empty_collection)
monkeypatch.setattr(main, "issues", empty_collection) monkeypatch.setattr(main, "issues", empty_collection)
monkeypatch.setattr(main, "pull_requests", empty_collection) monkeypatch.setattr(main, "pull_requests", empty_collection)
monkeypatch.setattr(main, "activity_events", empty_events) monkeypatch.setattr(main, "activity_events", empty_events)
monkeypatch.setattr(main, "_live_snapshot_response", empty_live_snapshot)
transport = httpx.ASGITransport(app=main.app) transport = httpx.ASGITransport(app=main.app, client=("127.0.0.1", 1234))
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client: async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
for path in ("/api/v1/context", "/api/v1/events", "/api/v1/live"): for path in ("/api/v1/context", "/api/v1/events", "/api/v1/live"):
response = await client.get(path) response = await client.get(path)