Skip to content

Commit

Permalink
Add failing test which tries to save the same content twice (jschneie…
Browse files Browse the repository at this point in the history
  • Loading branch information
melwas authored and nitely committed Jul 30, 2018
1 parent f93a02b commit 4514514
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_s3boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ def test_storage_save_gzip(self):
zfile = gzip.GzipFile(mode='rb', fileobj=content)
self.assertEqual(zfile.read(), b"I should be gzip'd")

def test_storage_save_gzip_twice(self):
"""
Test saving the same file content twice with gzip enabled.
"""
# Given
self.storage.gzip = True
name = 'test_storage_save.css'
content = ContentFile("I should be gzip'd")

# When
self.storage.save(name, content)
self.storage.save('test_storage_save_2.css', content)

# Then
obj = self.storage.bucket.Object.return_value
obj.upload_fileobj.assert_called_with(
mock.ANY,
ExtraArgs={
'ContentType': 'text/css',
'ContentEncoding': 'gzip',
'ACL': self.storage.default_acl,
}
)
args, kwargs = obj.upload_fileobj.call_args
content = args[0]
zfile = gzip.GzipFile(mode='rb', fileobj=content)
self.assertEqual(zfile.read(), b"I should be gzip'd")

def test_compress_content_len(self):
"""
Test that file returned by _compress_content() is readable.
Expand Down

0 comments on commit 4514514

Please sign in to comment.