def test_s3_upload_download_gzip(self):
    bucket_name = ('test-bucket-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    data = ('1234567890 ' * 100)
    upload_file_object = BytesIO()
    with gzip.GzipFile(fileobj=upload_file_object, mode='w') as filestream:
        filestream.write(data.encode('utf-8'))
    self.s3_client.put_object(Bucket=bucket_name, Key='test.gz', ContentEncoding='gzip', Body=upload_file_object.getvalue())
    downloaded_object = self.s3_client.get_object(Bucket=bucket_name, Key='test.gz')
    download_file_object = BytesIO(downloaded_object['Body'].read())
    with gzip.GzipFile(fileobj=download_file_object, mode='rb') as filestream:
        downloaded_data = filestream.read().decode('utf-8')
    self.assertEqual(downloaded_data, data)
def test_s3_upload_download_gzip(self):
    bucket_name = ('test-bucket-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    data = ('1234567890 ' * 100)
    upload_file_object = BytesIO()
    with gzip.GzipFile(fileobj=upload_file_object, mode='w') as filestream:
        filestream.write(data.encode('utf-8'))
    self.s3_client.put_object(Bucket=bucket_name, Key='test.gz', ContentEncoding='gzip', Body=upload_file_object.getvalue())
    downloaded_object = self.s3_client.get_object(Bucket=bucket_name, Key='test.gz')
    download_file_object = BytesIO(downloaded_object['Body'].read())
    with gzip.GzipFile(fileobj=download_file_object, mode='rb') as filestream:
        downloaded_data = filestream.read().decode('utf-8')
    self.assertEqual(downloaded_data, data)