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 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-06-01 18:14:54 +02:00
parent bfcc09958c
commit cc2825b3b7
+2 -1
View File
@@ -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):