@@ -414,27 +414,32 @@ def clem_junk_files(clem_visit_dir: Path):
414414 ],
415415}
416416
417- rsyncer_finalise_params_matrix : tuple [tuple [str , bool , bool ], ...] = (
418- # Workflow type | Use thread? | Use callback function?
419- ("clem" , False , False ),
420- ("clem" , False , True ),
421- ("clem" , True , False ),
422- ("clem" , True , True ),
423- )
424-
425417
426- @pytest .mark .parametrize ("test_params" , rsyncer_finalise_params_matrix )
418+ @pytest .mark .parametrize (
419+ "test_params" ,
420+ (
421+ # Workflow type | Use thread? | Use callback function? | Use blacklist?
422+ ("clem" , False , False , False ),
423+ ("clem" , False , False , True ),
424+ ("clem" , False , True , False ),
425+ ("clem" , False , True , True ),
426+ ("clem" , True , False , False ),
427+ ("clem" , True , False , True ),
428+ ("clem" , True , True , False ),
429+ ("clem" , True , True , True ),
430+ ),
431+ )
427432def test_rsyncer_finalise (
428433 mocker : MockerFixture ,
429434 rsync_module : str ,
430435 mock_server_url : MagicMock ,
431436 clem_visit_dir : Path ,
432437 clem_test_files : list [Path ],
433438 clem_junk_files : list [Path ],
434- test_params : tuple [str , bool , bool ],
439+ test_params : tuple [str , bool , bool , bool ],
435440):
436441 # Unpack test params
437- workflow_type , use_thread , use_callback = test_params
442+ workflow_type , use_thread , use_callback , use_blacklist = test_params
438443
439444 # Create a test end time
440445 timestamp = datetime .now ()
@@ -462,7 +467,7 @@ def test_rsyncer_finalise(
462467 rsync_module = rsync_module ,
463468 server_url = mock_server_url ,
464469 stop_callback = dummy_callback ,
465- substrings_blacklist = clem_substrings_blacklist ,
470+ substrings_blacklist = clem_substrings_blacklist if use_blacklist else {} ,
466471 end_time = timestamp ,
467472 )
468473 # Patch the 'queue' attribute with the mocked one
@@ -487,20 +492,26 @@ def test_rsyncer_finalise(
487492 assert rsyncer ._end_time is None
488493 assert rsyncer ._finalising
489494
490- # Check that list of files to transfer doesn't include blacklisted files
495+ # Check that list of files with and without using a blacklist are correct
491496 if use_thread :
492497 for file in clem_test_files :
493498 mock_queue .put .assert_any_call (file )
499+ if not use_blacklist :
500+ for file in clem_junk_files :
501+ mock_queue .put .assert_any_call (file )
494502 else :
495503 transfer_args = mock_transfer .call_args .args
496- assert sorted (transfer_args [0 ]) == sorted (clem_test_files )
504+ assert sorted (transfer_args [0 ]) == (
505+ sorted (clem_test_files )
506+ if use_blacklist
507+ else sorted ([* clem_test_files , * clem_junk_files ])
508+ )
497509
498- # Check that the blacklisted files no longer exist
499- for file in clem_junk_files :
500- assert not file .exists ()
501510 # Transfer is being mocked, so check that files to transfer are all present
502511 for file in clem_test_files :
503512 assert file .exists ()
513+ for file in clem_junk_files :
514+ assert not file .exists () if use_blacklist else file .exists ()
504515
505516 # Check that stop was called the correct number of times depending on the setup
506517 assert mock_stop .call_count == 2 if use_thread else 1
0 commit comments