1+ # pylint:disable=redefined-outer-name
2+
13import re
24
35import pytest
46from celery import Task
7+ from faker import Faker
58from models_library .progress_bar import ProgressReport , ProgressStructuredMessage
69from models_library .users import UserID
710from simcore_service_storage .api ._worker_tasks ._data_export import data_export
11+ from simcore_service_storage .modules .celery .models import TaskID
812
913pytest_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" )
1625async 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