def test_s3_multipart_upload_file(self):

    def upload(size_in_mb, bucket):
        file_name = '{}.tmp'.format(short_uid())
        path = '{}'.format(file_name)
        with open(path, 'wb') as f:
            f.seek(int((size_in_mb * 1000000.0)))
            f.write(b'\x00')
            f.flush()
            self.s3_client.upload_file(path, bucket, f'{file_name}', ExtraArgs={'StorageClass': 'DEEP_ARCHIVE'})
        os.remove(path)
    bucket_name = ('bucket-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    upload(1, bucket_name)
    upload(9, bucket_name)
    upload(15, bucket_name)
    s3_resource = aws_stack.connect_to_resource('s3')
    objects = s3_resource.Bucket(bucket_name).objects.all()
    keys = []
    for obj in objects:
        keys.append(obj.key)
        self.assertEqual(obj.storage_class, 'DEEP_ARCHIVE')
    self._delete_bucket(bucket_name, keys)
def test_s3_multipart_upload_file(self):

    def upload(size_in_mb, bucket):
        file_name = '{}.tmp'.format(short_uid())
        path = '{}'.format(file_name)
        with open(path, 'wb') as f:
            f.seek(int((size_in_mb * 1000000.0)))
            f.write(b'\x00')
            f.flush()
            self.s3_client.upload_file(path, bucket, f'{file_name}', ExtraArgs={'StorageClass': 'DEEP_ARCHIVE'})
        os.remove(path)
    bucket_name = ('bucket-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    upload(1, bucket_name)
    upload(9, bucket_name)
    upload(15, bucket_name)
    s3_resource = aws_stack.connect_to_resource('s3')
    objects = s3_resource.Bucket(bucket_name).objects.all()
    keys = []
    for obj in objects:
        keys.append(obj.key)
        self.assertEqual(obj.storage_class, 'DEEP_ARCHIVE')
    self._delete_bucket(bucket_name, keys)