28
28
import pytest
29
29
import tempfile
30
30
import os
31
+ import datetime
31
32
32
33
from unittest .mock import AsyncMock , Mock , patch
33
34
from servicex .dataset_identifier import FileListDataset
@@ -120,16 +121,21 @@ async def test_as_files_cached(transformed_result, python_dataset):
120
121
@pytest .mark .asyncio
121
122
async def test_download_files (python_dataset ):
122
123
signed_urls_only = False
124
+ begin_at = datetime .datetime .now (tz = datetime .timezone .utc )
123
125
download_progress = "download_task_id"
124
126
minio_mock = AsyncMock ()
125
127
config = Configuration (cache_path = "temp_dir" , api_endpoints = [])
126
128
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
+
127
137
minio_mock .download_file .return_value = Path ("/path/to/downloaded_file" )
128
138
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
- ]
133
139
134
140
progress_mock = Mock ()
135
141
python_dataset .minio_polling_interval = 0
@@ -138,7 +144,7 @@ async def test_download_files(python_dataset):
138
144
python_dataset .configuration .shortened_downloaded_filename = False
139
145
140
146
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
142
148
)
143
149
minio_mock .download_file .assert_awaited ()
144
150
minio_mock .get_signed_url .assert_not_awaited ()
@@ -148,25 +154,29 @@ async def test_download_files(python_dataset):
148
154
@pytest .mark .asyncio
149
155
async def test_download_files_with_signed_urls (python_dataset ):
150
156
signed_urls_only = True
157
+ begin_at = datetime .datetime .now (tz = datetime .timezone .utc )
151
158
download_progress = "download_task_id"
152
159
minio_mock = AsyncMock ()
153
160
config = Configuration (cache_path = "temp_dir" , api_endpoints = [])
154
161
python_dataset .configuration = config
155
162
minio_mock .download_file .return_value = "/path/to/downloaded_file"
156
163
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
- ]
161
164
progress_mock = Mock ()
162
165
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
+ )
163
173
python_dataset .minio_polling_interval = 0
164
174
python_dataset .minio = minio_mock
165
175
python_dataset .current_status = Mock (status = "Complete" , files_completed = 2 )
166
176
python_dataset .configuration .shortened_downloaded_filename = False
167
177
168
178
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
170
180
)
171
181
minio_mock .download_file .assert_not_called ()
172
182
minio_mock .get_signed_url .assert_called ()
0 commit comments