def test_download_with_override(
         self,
         boto3_resource: MagicMock,
         os_path_isfile_function: MagicMock):
     sut = S3BucketObjectDownloader()
     self.assertEqual(1, boto3_resource.call_count)
     sut.download(
         bucket="test_bucket",
         key="test_key",
         target_path_and_name="test_target_path",
         override_existing_file=True
     )
     self.assertEqual(1, boto3_resource.call_count)
     self.assertEqual(0, os_path_isfile_function.call_count)
Beispiel #2
0
 def test_download_with_no_override(
         self,
         boto3_resource: MagicMock,
         os_path_is_file: MagicMock,
         os_path_is_dir: MagicMock
 ):
     sut = S3BucketObjectDownloader()
     self.assertEqual(1, boto3_resource.call_count)
     with self.assertRaises(FileExistsError):
         sut.download(
             bucket="test_bucket",
             key="test_key",
             target_path_and_name="test_target_path",
             override_existing_file=False
         )
     self.assertEqual(1, boto3_resource.call_count)
     self.assertEqual(1, os_path_is_file.call_count)
Beispiel #3
0
 def __get_s3_bucket_object_downloader(self) -> S3BucketObjectDownloader:
     s3_bucket_object_downloader: S3BucketObjectDownloader = \
         S3BucketObjectDownloader(credentials=self.__aws_credentials)
     return s3_bucket_object_downloader