Skip to content

Commit a796af3

Browse files
author
Andrei Neagu
committed
refactor
1 parent 87ba884 commit a796af3

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

services/storage/src/simcore_service_storage/modules/celery/worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def __init__(self, celery_app: Celery) -> None:
1414

1515
@make_async()
1616
def set_task_progress(self, task: Task, report: ProgressReport) -> None:
17-
assert task.name # nosec
17+
if task.name is None:
18+
_logger.debug("skipping task progress for task.name='%s'", task.name)
19+
return
20+
1821
task_name = task.name
1922
task_id = task.request.id
2023

services/storage/tests/unit/test_api__worker_tasks__paths.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# pylint:disable=unused-argument
77
# pylint:disable=unused-variable
88

9-
109
import random
10+
import re
1111
from pathlib import Path
1212
from typing import Any, TypeAlias
1313

@@ -22,7 +22,11 @@
2222
from pytest_simcore.helpers.storage_utils import FileIDDict, ProjectWithFilesParams
2323
from simcore_service_storage.api._worker_tasks._data_export import data_export
2424
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
2630
from simcore_service_storage.simcore_s3_dsm import SimcoreS3DataManager
2731

2832
pytest_simcore_core_services_selection = [
@@ -72,6 +76,7 @@ def fake_celery_task(celery_app: Celery, initialized_app: FastAPI) -> Task:
7276
celery_task = Task()
7377
celery_task.app = celery_app
7478
set_fastapi_app(celery_app, initialized_app)
79+
set_celery_worker_client(celery_app, CeleryWorkerClient(celery_app))
7580
return celery_task
7681

7782

@@ -221,12 +226,9 @@ async def test_path_compute_size_inexistent_path(
221226

222227

223228
# 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):
231230
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

Comments
 (0)