Skip to content

Commit

Permalink
Add failing test which tries to save the same content twice (#371)
Browse files Browse the repository at this point in the history
See: #367
  • Loading branch information
melwas authored and jschneier committed Aug 14, 2017
1 parent 7db22ef commit 0371a4c
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 0371a4c

Please sign in to comment.