Skip to content

Commit 693aff4

Browse files
committed
Reorder tests
1 parent 3573aee commit 693aff4

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

tests/app/test_datasets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def dataset():
6464
return cached_dataset
6565

6666

67-
@pytest.mark.asyncio
6867
def test_datasets_list(script_runner, dataset):
6968
with patch("servicex.app.datasets.ServiceXClient") as mock_servicex:
7069
mock_get_datasets = AsyncMock(return_value=[dataset])

tests/test_minio_adapter.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@
3434
from servicex.minio_adapter import MinioAdapter
3535
from servicex.models import ResultFile
3636

37-
import asyncio
38-
3937
DOWNLOAD_PATCH_COUNTER = 0
4038

41-
_semaphore = asyncio.Semaphore(1)
42-
4339

4440
def mock_downloader(**args):
4541
global DOWNLOAD_PATCH_COUNTER
@@ -70,16 +66,15 @@ def minio_adapter(moto_services, moto_patch_session) -> MinioAdapter:
7066

7167
@fixture
7268
async def populate_bucket(request, minio_adapter):
73-
async with _semaphore:
74-
async with minio_adapter.minio.client(
75-
"s3", endpoint_url=minio_adapter.endpoint_host
76-
) as s3:
77-
await s3.create_bucket(Bucket=minio_adapter.bucket)
78-
await s3.put_object(
79-
Bucket=minio_adapter.bucket, Key=request.param, Body=b"\x01" * 10
80-
)
81-
yield
82-
await s3.delete_object(Bucket=minio_adapter.bucket, Key=request.param)
69+
async with minio_adapter.minio.client(
70+
"s3", endpoint_url=minio_adapter.endpoint_host
71+
) as s3:
72+
await s3.create_bucket(Bucket=minio_adapter.bucket)
73+
await s3.put_object(
74+
Bucket=minio_adapter.bucket, Key=request.param, Body=b"\x01" * 10
75+
)
76+
yield
77+
await s3.delete_object(Bucket=minio_adapter.bucket, Key=request.param)
8378

8479

8580
@fixture
@@ -180,33 +175,33 @@ async def test_download_short_filename_change(minio_adapter, populate_bucket):
180175

181176
@pytest.mark.parametrize("populate_bucket", ["test.txt"], indirect=True)
182177
@pytest.mark.asyncio
178+
async def test_download_file_retry(download_patch, minio_adapter, populate_bucket):
179+
result = await minio_adapter.download_file("test.txt", local_dir="/tmp/foo")
180+
assert str(result).endswith("test.txt")
181+
assert result.exists()
182+
assert len(download_patch.call_args_list) == 3
183+
result.unlink()
184+
185+
186+
@pytest.mark.parametrize("populate_bucket", ["test2.txt"], indirect=True)
187+
@pytest.mark.asyncio
183188
async def test_download_repeat(minio_adapter, populate_bucket):
184189
import asyncio
185190

186191
print(await minio_adapter.list_bucket())
187-
result = await minio_adapter.download_file("test.txt", local_dir="/tmp/foo")
188-
assert str(result).endswith("test.txt")
192+
result = await minio_adapter.download_file("test2.txt", local_dir="/tmp/foo")
193+
assert str(result).endswith("test2.txt")
189194
assert result.exists()
190195
t0 = result.stat().st_mtime_ns
191196
await asyncio.sleep(4) # hopefully long enough for Windows/FAT32 ... ?
192197

193-
result2 = await minio_adapter.download_file("test.txt", local_dir="/tmp/foo")
198+
result2 = await minio_adapter.download_file("test2.txt", local_dir="/tmp/foo")
194199
assert result2.exists()
195200
assert result2 == result
196201
assert t0 == result2.stat().st_mtime_ns
197202
result.unlink() # it should exist, from above ...
198203

199204

200-
@pytest.mark.parametrize("populate_bucket", ["test.txt"], indirect=True)
201-
@pytest.mark.asyncio
202-
async def test_download_file_retry(download_patch, minio_adapter, populate_bucket):
203-
result = await minio_adapter.download_file("test.txt", local_dir="/tmp/foo")
204-
assert str(result).endswith("test.txt")
205-
assert result.exists()
206-
assert len(download_patch.call_args_list) == 3
207-
result.unlink()
208-
209-
210205
@pytest.mark.asyncio
211206
async def test_get_signed_url(minio_adapter, moto_services):
212207
result = await minio_adapter.get_signed_url("test.txt")

0 commit comments

Comments
 (0)