From 115ecd2351379890caa99e3b13a64356c86395b5 Mon Sep 17 00:00:00 2001 From: CC Worker Date: Sat, 6 Jun 2026 22:56:45 +0000 Subject: [PATCH] test(exam): mock service-role files read in source-pdf download test (S4-8.1) The download path now resolves the files row via SupabaseServiceRoleClient (to sidestep the cabinet_memberships RLS recursion); the test must mock it like the upload test does. Test-only. Co-Authored-By: Claude Opus 4.8 --- tests/test_exam_templates.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_exam_templates.py b/tests/test_exam_templates.py index 346108c..01421c6 100644 --- a/tests/test_exam_templates.py +++ b/tests/test_exam_templates.py @@ -214,6 +214,9 @@ def test_get_template_source_pdf_from_uploaded_file(monkeypatch): } client, _ = make_client(store=store) monkeypatch.setattr(templates_mod, "StorageAdmin", _FakeStorageAdmin) + # The download resolves the files row via service role (sidesteps the broken cabinet_memberships + # RLS recursion) — mock it to the same fake store, like the upload test does. + monkeypatch.setattr(templates_mod, "SupabaseServiceRoleClient", lambda: _FakeServiceRoleClient(store)) resp = client.get("/api/exam/templates/t1/source-pdf") assert resp.status_code == 200 assert resp.headers["content-type"].startswith("application/pdf")