|
6 | 6 | # pylint:disable=unused-argument |
7 | 7 | # pylint:disable=unused-variable |
8 | 8 |
|
9 | | - |
10 | 9 | import random |
| 10 | +import re |
11 | 11 | from pathlib import Path |
12 | 12 | from typing import Any, TypeAlias |
13 | 13 |
|
|
22 | 22 | from pytest_simcore.helpers.storage_utils import FileIDDict, ProjectWithFilesParams |
23 | 23 | from simcore_service_storage.api._worker_tasks._data_export import data_export |
24 | 24 | from simcore_service_storage.api._worker_tasks._paths import compute_path_size |
25 | | -from simcore_service_storage.modules.celery.utils import set_fastapi_app |
| 25 | +from simcore_service_storage.modules.celery.utils import ( |
| 26 | + set_celery_worker_client, |
| 27 | + set_fastapi_app, |
| 28 | +) |
| 29 | +from simcore_service_storage.modules.celery.worker import CeleryWorkerClient |
26 | 30 | from simcore_service_storage.simcore_s3_dsm import SimcoreS3DataManager |
27 | 31 |
|
28 | 32 | pytest_simcore_core_services_selection = [ |
@@ -72,6 +76,7 @@ def fake_celery_task(celery_app: Celery, initialized_app: FastAPI) -> Task: |
72 | 76 | celery_task = Task() |
73 | 77 | celery_task.app = celery_app |
74 | 78 | set_fastapi_app(celery_app, initialized_app) |
| 79 | + set_celery_worker_client(celery_app, CeleryWorkerClient(celery_app)) |
75 | 80 | return celery_task |
76 | 81 |
|
77 | 82 |
|
@@ -221,12 +226,9 @@ async def test_path_compute_size_inexistent_path( |
221 | 226 |
|
222 | 227 |
|
223 | 228 | # TODO: refactor and extract common parts |
224 | | -async def test_data_export( |
225 | | - fake_celery_task: Task, |
226 | | - initialized_app: FastAPI, |
227 | | - client: httpx.AsyncClient, |
228 | | - user_id: UserID, |
229 | | -): |
230 | | - # TODO: fake celery_worker_client as well |
| 229 | +async def test_data_export(fake_celery_task: Task, user_id: UserID): |
231 | 230 | data = await data_export(fake_celery_task, user_id=user_id, paths_to_export=[]) |
232 | | - assert data == "alskdjalsdjasjkd" |
| 231 | + assert re.fullmatch( |
| 232 | + rf"^exports/{user_id}/[0-9a-fA-F]{{8}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{12}}\.zip$", |
| 233 | + data, |
| 234 | + ) |
0 commit comments