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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user