@@ -679,6 +679,39 @@ def test_submit_move_adds_delete_source_subscriber(self):
679
679
for i , actual_subscriber in enumerate (actual_subscribers ):
680
680
self .assertIsInstance (actual_subscriber , ref_subscribers [i ])
681
681
682
+ def test_submit_with_no_overwrite_flag_when_file_exists_at_destination (
683
+ self ,
684
+ ):
685
+ # Setting up the CLI params with no_overwrite flag as True
686
+ self .cli_params ['no_overwrite' ] = True
687
+ fileinfo = self .create_file_info (self .key )
688
+ # Mocking os.path.exists to simulate that file already exists
689
+ with mock .patch ('os.path.exists' , return_value = True ):
690
+ # Submitting download request
691
+ future = self .transfer_request_submitter .submit (fileinfo )
692
+ # Asserting that the future is None, as the file already exists
693
+ self .assertIsNone (future )
694
+ # Asserting that no download happened
695
+ self .assert_no_downloads_happened ()
696
+
697
+ def test_submit_with_no_overwrite_flag_when_file_does_not_exist_at_destination (
698
+ self ,
699
+ ):
700
+ # Setting up the CLI params with no_overwrite flag as True
701
+ self .cli_params ['no_overwrite' ] = True
702
+ fileinfo = self .create_file_info (self .key )
703
+ # Mocking os.path.exists to return False, to simulate that file does not exist
704
+ with mock .patch ('os.path.exists' , return_value = False ):
705
+ # Submitting download request
706
+ future = self .transfer_request_submitter .submit (fileinfo )
707
+ # Asserting that the future is the same object returned by transfer_manager.download
708
+ # This confirms that download was actually initiated
709
+ self .assertIs (self .transfer_manager .download .return_value , future )
710
+ # Asserting that download happened
711
+ self .assertEqual (
712
+ len (self .transfer_manager .download .call_args_list ), 1
713
+ )
714
+
682
715
683
716
class TestCopyRequestSubmitter (BaseTransferRequestSubmitterTest ):
684
717
def setUp (self ):
0 commit comments