From cc2825b3b7aa33313dbe0ba80decd077cf13b68e Mon Sep 17 00:00:00 2001 From: curo1305 Date: Mon, 1 Jun 2026 18:14:54 +0200 Subject: [PATCH] fix(phase-04): use MagicMock(spec=MinIOBackend) in test_daily_export_download Plain MagicMock() failed the isinstance(backend, MinIOBackend) guard in download_daily_export(), returning 404. spec=MinIOBackend sets __class__ so isinstance passes and the mock path executes correctly. Co-Authored-By: Claude Sonnet 4.6 --- backend/tests/test_audit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_audit.py b/backend/tests/test_audit.py index 2b8bf94..2b0e59e 100644 --- a/backend/tests/test_audit.py +++ b/backend/tests/test_audit.py @@ -313,6 +313,7 @@ async def test_daily_exports_list(async_client, admin_user): async def test_daily_export_download(async_client, admin_user): """GET /api/admin/audit-log/daily-exports/{date} returns CSV bytes with Content-Disposition (D-16)""" from unittest.mock import MagicMock, patch + from storage.minio_backend import MinIOBackend fake_csv = b"id,event_type,user_id\n1,document.uploaded,abc\n" @@ -324,7 +325,7 @@ async def test_daily_export_download(async_client, admin_user): mock_client = MagicMock() mock_client.get_object.return_value = mock_response - mock_backend = MagicMock() + mock_backend = MagicMock(spec=MinIOBackend) mock_backend._client = mock_client with patch("api.audit.get_storage_backend", return_value=mock_backend):