def test_get_only_different_files(self):
     with patch.object(self.s3, 
                       'list_objects',
                       return_value={'Contents':
                                         [{'Key': 'test1', 'ETag': '"acbd18db4cc2f85cedef654fccc4a4d8"'}]}):
         interface = S3Interface(self.s3)
         result = interface.get_files_to_upload(self.bucket_name, 'tmp')
         self.assertEqual([], result)
Exemplo n.º 2
0
 def test_retrieve_file_info_from_bucket(self, patched_session):
     interface = S3Interface('test')
     with patch.object(
             interface.s3,
             'list_objects',
             return_value={'Contents': ['test1', 'test2', 'test3']}):
         retrieved_files = interface.get_remote_files(self.bucket_name)
         self.assertEqual(['test1', 'test2', 'test3'], retrieved_files)
Exemplo n.º 3
0
 def test_delete_file_from_bucket(self, patched_session):
     interface = S3Interface('test')
     with patch.object(interface.s3,
                       'delete_objects',
                       return_value={'Deleted': ['test1']}):
         deleted_files = interface.delete_aws_files([{
             'Key': 'test1'
         }], self.bucket_name)
         self.assertEqual(['test1'], deleted_files)
Exemplo n.º 4
0
def main():
    s3_interface = S3Interface(s3)
    if args.delete_removed:
        print('Deleted files:')
        s3_interface.delete_removed_files(args.local_path, args.bucket_name)

    if args.etag:
        print('\nUploading files')
        s3_interface.upload_only_different_files(args.bucket_name,
                                                 args.local_path)
    else:
        print('\nUploading files')
        s3_interface.upload_files_from_local_path(args.bucket_name,
                                                  args.local_path)