Skip to content

Commit 36cb4aa

Browse files
committed
fix breaking tests
1 parent ccfe38c commit 36cb4aa

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

tests/test_dataset.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import pytest
2929
import tempfile
3030
import os
31+
import datetime
3132

3233
from unittest.mock import AsyncMock, Mock, patch
3334
from servicex.dataset_identifier import FileListDataset
@@ -120,16 +121,21 @@ async def test_as_files_cached(transformed_result, python_dataset):
120121
@pytest.mark.asyncio
121122
async def test_download_files(python_dataset):
122123
signed_urls_only = False
124+
begin_at = datetime.datetime.now(tz=datetime.timezone.utc)
123125
download_progress = "download_task_id"
124126
minio_mock = AsyncMock()
125127
config = Configuration(cache_path="temp_dir", api_endpoints=[])
126128
python_dataset.configuration = config
129+
python_dataset.servicex = AsyncMock()
130+
python_dataset.servicex.get_transformation_results = AsyncMock(
131+
side_effect=[
132+
[{"file-path": "file1.txt"}],
133+
[{"file-path": "file2.txt"}],
134+
]
135+
)
136+
127137
minio_mock.download_file.return_value = Path("/path/to/downloaded_file")
128138
minio_mock.get_signed_url.return_value = Path("http://example.com/signed_url")
129-
minio_mock.list_bucket.return_value = [
130-
Mock(filename="file1.txt"),
131-
Mock(filename="file2.txt"),
132-
]
133139

134140
progress_mock = Mock()
135141
python_dataset.minio_polling_interval = 0
@@ -138,7 +144,7 @@ async def test_download_files(python_dataset):
138144
python_dataset.configuration.shortened_downloaded_filename = False
139145

140146
result_uris = await python_dataset.download_files(
141-
signed_urls_only, progress_mock, download_progress, None
147+
signed_urls_only, progress_mock, download_progress, None, begin_at
142148
)
143149
minio_mock.download_file.assert_awaited()
144150
minio_mock.get_signed_url.assert_not_awaited()
@@ -148,25 +154,29 @@ async def test_download_files(python_dataset):
148154
@pytest.mark.asyncio
149155
async def test_download_files_with_signed_urls(python_dataset):
150156
signed_urls_only = True
157+
begin_at = datetime.datetime.now(tz=datetime.timezone.utc)
151158
download_progress = "download_task_id"
152159
minio_mock = AsyncMock()
153160
config = Configuration(cache_path="temp_dir", api_endpoints=[])
154161
python_dataset.configuration = config
155162
minio_mock.download_file.return_value = "/path/to/downloaded_file"
156163
minio_mock.get_signed_url.return_value = "http://example.com/signed_url"
157-
minio_mock.list_bucket.return_value = [
158-
Mock(filename="file1.txt"),
159-
Mock(filename="file2.txt"),
160-
]
161164
progress_mock = Mock()
162165

166+
python_dataset.servicex = AsyncMock()
167+
python_dataset.servicex.get_transformation_results = AsyncMock(
168+
side_effect=[
169+
[{"file-path": "file1.txt"}],
170+
[{"file-path": "file2.txt"}],
171+
]
172+
)
163173
python_dataset.minio_polling_interval = 0
164174
python_dataset.minio = minio_mock
165175
python_dataset.current_status = Mock(status="Complete", files_completed=2)
166176
python_dataset.configuration.shortened_downloaded_filename = False
167177

168178
result_uris = await python_dataset.download_files(
169-
signed_urls_only, progress_mock, download_progress, None
179+
signed_urls_only, progress_mock, download_progress, None, begin_at
170180
)
171181
minio_mock.download_file.assert_not_called()
172182
minio_mock.get_signed_url.assert_called()

0 commit comments

Comments
 (0)