@@ -122,7 +122,7 @@ async def my_callback(did_name: str, info: Dict[str, Any]):
122
122
'adler32' : 'no clue' ,
123
123
'file_size' : 22323 ,
124
124
'file_events' : 0
125
- })
125
+ })
126
126
SXAdaptor .put_fileset_complete .assert_called_once ()
127
127
128
128
@@ -154,6 +154,39 @@ async def my_callback(did_name: str, info: Dict[str, Any]):
154
154
SXAdaptor .put_fileset_complete .assert_called_once ()
155
155
156
156
157
+ def test_bulk_file_call_with_param (rabbitmq , SXAdaptor ):
158
+ 'Test a working, simple, two file call with parameter'
159
+
160
+ seen_name = None
161
+
162
+ async def my_callback (did_name : str , info : Dict [str , Any ]):
163
+ nonlocal seen_name
164
+ seen_name = did_name
165
+ yield [{
166
+ 'paths' : ["fork/it/over" ],
167
+ 'adler32' : 'no clue' ,
168
+ 'file_size' : 22323 ,
169
+ 'file_events' : 0 ,
170
+ }, {
171
+ 'paths' : ["fork/it/over" ],
172
+ 'adler32' : 'no clue' ,
173
+ 'file_size' : 22323 ,
174
+ 'file_events' : 0 ,
175
+ }]
176
+
177
+ init_rabbit_mq (my_callback , 'http://myrabbit.com' , 'test_queue_name' , retries = 12 ,
178
+ retry_interval = 10 )
179
+
180
+ rabbitmq .send_did_request ('hithere?files=10' )
181
+
182
+ # Make sure callback was called
183
+ assert seen_name == 'hithere'
184
+
185
+ # Make sure the file was sent along, along with the completion
186
+ SXAdaptor .put_file_add .assert_called_once ()
187
+ SXAdaptor .put_fileset_complete .assert_called_once ()
188
+
189
+
157
190
def test_with_scope (rabbitmq , SXAdaptor ):
158
191
seen_name : Optional [str ] = None
159
192
@@ -389,6 +422,41 @@ async def my_user_callback(did, info):
389
422
assert SXAdaptor .post_status_update .called_once ()
390
423
391
424
425
+ @pytest .mark .asyncio
426
+ async def test_run_file_bulk_fetch_loop (SXAdaptor , mocker ):
427
+ async def my_user_callback (did , info ):
428
+ return_values = [
429
+ {
430
+ 'paths' : ['/tmp/foo' ],
431
+ 'adler32' : '13e4f' ,
432
+ 'file_size' : 1024 ,
433
+ 'file_events' : 128
434
+ },
435
+ {
436
+ 'paths' : ['/tmp/bar' ],
437
+ 'adler32' : 'f33d' ,
438
+ 'file_size' : 2046 ,
439
+ 'file_events' : 64
440
+ }
441
+ ]
442
+ yield return_values
443
+
444
+ await run_file_fetch_loop ("123-456" , SXAdaptor , {}, my_user_callback )
445
+ SXAdaptor .post_transform_start .assert_called_once ()
446
+
447
+ assert SXAdaptor .put_file_add .call_count == 1
448
+ assert SXAdaptor .put_file_add .call_args_list [0 ][0 ][0 ]['paths' ][0 ] == '/tmp/foo'
449
+ assert SXAdaptor .put_file_add .call_args_list [1 ][0 ][0 ]['paths' ][0 ] == '/tmp/bar'
450
+
451
+ SXAdaptor .put_fileset_complete .assert_called_once
452
+ assert SXAdaptor .put_fileset_complete .call_args [0 ][0 ]['files' ] == 2
453
+ assert SXAdaptor .put_fileset_complete .call_args [0 ][0 ]['files-skipped' ] == 0
454
+ assert SXAdaptor .put_fileset_complete .call_args [0 ][0 ]['total-events' ] == 192
455
+ assert SXAdaptor .put_fileset_complete .call_args [0 ][0 ]['total-bytes' ] == 3070
456
+
457
+ assert SXAdaptor .post_status_update .called_once ()
458
+
459
+
392
460
@pytest .mark .asyncio
393
461
async def test_run_file_fetch_one (SXAdaptor , mocker ):
394
462
async def my_user_callback (did , info ):
@@ -479,7 +547,7 @@ async def my_user_callback(did, info):
479
547
assert SXAdaptor .put_file_add .call_args_list [0 ][0 ][0 ]['paths' ] == [
480
548
'/tmp/bar' ,
481
549
'others:/tmp/bar'
482
- ]
550
+ ]
483
551
484
552
SXAdaptor .put_fileset_complete .assert_called_once
485
553
assert SXAdaptor .put_fileset_complete .call_args [0 ][0 ]['files' ] == 1
0 commit comments