|
1 | | -import pytest |
2 | 1 | from unittest.mock import MagicMock, patch |
3 | 2 |
|
| 3 | +import pytest |
4 | 4 | from fastapi.testclient import TestClient |
5 | 5 | from sqlmodel import Session |
6 | 6 |
|
7 | | -from app.models import EvaluationDataset, EvaluationRun, File, FileType |
8 | | -from app.models.stt_evaluation import STTSample, STTResult, EvaluationType |
| 7 | +from app.core.util import now |
9 | 8 | from app.crud.language import get_language_by_locale |
| 9 | +from app.models import EvaluationDataset, EvaluationRun, File, FileType |
| 10 | +from app.models.stt_evaluation import EvaluationType, STTResult, STTSample |
10 | 11 | from app.tests.utils.auth import TestAuthContext |
11 | | -from app.core.util import now |
12 | 12 |
|
13 | 13 |
|
14 | 14 | # Helper functions |
@@ -741,9 +741,7 @@ def test_get_stt_dataset_signed_url_failure( |
741 | 741 | """Test getting an STT dataset when signed URL generation fails.""" |
742 | 742 | # Mock cloud storage to raise an exception |
743 | 743 | mock_storage = MagicMock() |
744 | | - mock_storage.get_signed_url.side_effect = Exception( |
745 | | - "Failed to generate signed URL" |
746 | | - ) |
| 744 | + mock_storage.get_signed_url.return_value = None |
747 | 745 | mock_get_cloud_storage.return_value = mock_storage |
748 | 746 |
|
749 | 747 | dataset = create_test_stt_dataset( |
@@ -1076,9 +1074,7 @@ def test_get_stt_run_signed_url_failure( |
1076 | 1074 | """Test getting an STT run when signed URL generation fails.""" |
1077 | 1075 | # Mock cloud storage to raise an exception |
1078 | 1076 | mock_storage = MagicMock() |
1079 | | - mock_storage.get_signed_url.side_effect = Exception( |
1080 | | - "Failed to generate signed URL" |
1081 | | - ) |
| 1077 | + mock_storage.get_signed_url.return_value = None |
1082 | 1078 | mock_get_cloud_storage.return_value = mock_storage |
1083 | 1079 |
|
1084 | 1080 | # Create dataset, sample, run, and result |
@@ -1278,7 +1274,7 @@ def test_list_audio_files_with_signed_urls( |
1278 | 1274 | mock_get_cloud_storage.return_value = mock_storage |
1279 | 1275 |
|
1280 | 1276 | # Create test file |
1281 | | - file = create_test_file( |
| 1277 | + _file = create_test_file( |
1282 | 1278 | db=db, |
1283 | 1279 | organization_id=user_api_key.organization_id, |
1284 | 1280 | project_id=user_api_key.project_id, |
@@ -1314,7 +1310,7 @@ def test_list_audio_files_without_signed_urls( |
1314 | 1310 | ) -> None: |
1315 | 1311 | """Test listing audio files without signed URLs.""" |
1316 | 1312 | # Create test file |
1317 | | - file = create_test_file( |
| 1313 | + _file = create_test_file( |
1318 | 1314 | db=db, |
1319 | 1315 | organization_id=user_api_key.organization_id, |
1320 | 1316 | project_id=user_api_key.project_id, |
@@ -1345,7 +1341,7 @@ def test_list_audio_files_project_isolation( |
1345 | 1341 | ) -> None: |
1346 | 1342 | """Test that audio files are isolated by project.""" |
1347 | 1343 | # Create file in user's project |
1348 | | - user_file = create_test_file( |
| 1344 | + _user_file = create_test_file( |
1349 | 1345 | db=db, |
1350 | 1346 | organization_id=user_api_key.organization_id, |
1351 | 1347 | project_id=user_api_key.project_id, |
|
0 commit comments