Skip to content

Commit 8badfd2

Browse files
author
Andrei Neagu
committed
fixed tests
1 parent bb38d8b commit 8badfd2

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

services/storage/tests/unit/api/_worker_tasks/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ def mock_task_progress(mocker: MockerFixture) -> list[ProgressReport]:
2424
progress_updates = []
2525

2626
async def _progress(*args, **_) -> None:
27-
progress_updates.append(args[1])
27+
progress_updates.append(args[2])
2828

2929
mocker.patch(
30-
"simcore_service_storage.modules.celery.worker.CeleryWorkerClient.set_task_progress",
30+
"simcore_service_storage.modules.celery.worker.CeleryTaskQueueWorker.set_task_progress",
3131
side_effect=_progress,
3232
)
3333
return progress_updates
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
# pylint:disable=redefined-outer-name
2+
13
import re
24

35
import pytest
46
from celery import Task
7+
from faker import Faker
58
from models_library.progress_bar import ProgressReport, ProgressStructuredMessage
69
from models_library.users import UserID
710
from simcore_service_storage.api._worker_tasks._data_export import data_export
11+
from simcore_service_storage.modules.celery.models import TaskID
812

913
pytest_simcore_core_services_selection = [
1014
"postgres",
1115
"rabbit",
1216
]
1317

1418

19+
@pytest.fixture
20+
def fake_task_id(faker: Faker) -> TaskID:
21+
return f"{faker.uuid4()}"
22+
23+
1524
@pytest.mark.usefixtures("celery_worker")
1625
async def test_data_export(
17-
mock_task_progress: list[ProgressReport], fake_celery_task: Task, user_id: UserID
26+
mock_task_progress: list[ProgressReport],
27+
fake_celery_task: Task,
28+
user_id: UserID,
29+
fake_task_id: TaskID,
1830
):
19-
result = await data_export(fake_celery_task, user_id=user_id, paths_to_export=[])
31+
result = await data_export(
32+
fake_celery_task, fake_task_id, user_id=user_id, paths_to_export=[]
33+
)
2034
assert re.fullmatch(
2135
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$",
2236
result,
@@ -29,11 +43,7 @@ async def test_data_export(
2943
attempt=0,
3044
unit=None,
3145
message=ProgressStructuredMessage(
32-
description="create and upload export",
33-
current=0.0,
34-
total=1,
35-
unit=None,
36-
sub=None,
46+
description="data export", current=0.0, total=1, unit=None, sub=None
3747
),
3848
),
3949
ProgressReport(
@@ -42,11 +52,7 @@ async def test_data_export(
4252
attempt=0,
4353
unit=None,
4454
message=ProgressStructuredMessage(
45-
description="create and upload export",
46-
current=1.0,
47-
total=1,
48-
unit=None,
49-
sub=None,
55+
description="data export", current=1.0, total=1, unit=None, sub=None
5056
),
5157
),
5258
]

0 commit comments

Comments
 (0)