Skip to content

Commit

Permalink
fixup! [AIRFLOW-4438] Add Gzip compression to S3_hook (#7680)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxil committed Mar 20, 2020
1 parent 5fca34f commit bb56b00
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/hooks/test_s3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#

import gzip as gz

import io
import mock
import tempfile
import unittest
Expand Down Expand Up @@ -271,12 +271,12 @@ def test_load_string(self):

@mock_s3
def test_load_string_acl(self):
hook = S3Hook()
hook = S3Hook(aws_conn_id=None)
conn = hook.get_conn()
# We need to create the bucket since this is all in Moto's 'virtual'
# AWS account
conn.create_bucket(Bucket="mybucket")
hook.load_string("Contént", "my_key", "mybucket",
hook.load_string(u"Contént", "my_key", "mybucket",
acl_policy='public-read')
response = boto3.client('s3').get_object_acl(Bucket="mybucket",
Key="my_key", RequestPayer='requester')
Expand Down Expand Up @@ -325,7 +325,8 @@ def test_load_file_gzip(self):
temp_file.seek(0)
hook.load_file(temp_file, "my_key", 'mybucket', gzip=True)
resource = boto3.resource('s3').Object('mybucket', 'my_key') # pylint: disable=no-member
assert gz.decompress(resource.get()['Body'].read()) == b'Content'
with gz.GzipFile(fileobj=io.BytesIO(resource.get()['Body'].read())) as gzfile:
assert gzfile.read() == b'Content'

@mock_s3
def test_load_file_acl(self):
Expand Down

0 comments on commit bb56b00

Please sign in to comment.