Skip to content

Commit

Permalink
Merge pull request #60 from jschneier/gs-is-gzipped-bad-name
Browse files Browse the repository at this point in the history
change Google Storage setting to gzip from is_gzipped
  • Loading branch information
jschneier committed Aug 14, 2015
2 parents d04064d + 72fb8be commit 4b23315
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion storages/backends/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GSBotoStorage(S3BotoStorage):
calling_format = setting('GS_CALLING_FORMAT', SubdomainCallingFormat())
secure_urls = setting('GS_SECURE_URLS', True)
file_name_charset = setting('GS_FILE_NAME_CHARSET', 'utf-8')
is_gzipped = setting('GS_IS_GZIPPED', False)
gzip = setting('GS_IS_GZIPPED', False)
preload_metadata = setting('GS_PRELOAD_METADATA', False)
gzip_content_types = setting('GS_GZIP_CONTENT_TYPES', (
'text/css',
Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

DEFAULT_FILE_STORAGE = 'backends.s3boto.S3BotoStorage'
AWS_IS_GZIPPED = True
GS_IS_GZIPPED = True
SECRET_KEY = 'hailthesunshine'

32 changes: 32 additions & 0 deletions tests/test_gs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.test import TestCase
from django.core.files.base import ContentFile

from storages.backends import gs, s3boto

try:
from unittest import mock
except ImportError: # Python 3.2 and below
import mock


class GSBotoTestCase(TestCase):
@mock.patch('storages.backends.gs.GSConnection')
def setUp(self, GSConnection):
self.storage = gs.GSBotoStorage()
self.storage._connection = mock.MagicMock()


class GSStorageTestCase(GSBotoTestCase):
def test_gs_gzip(self):
s3boto.S3BotoStorage.gzip = False
name = 'test_storage_save.css'
content = ContentFile("I should be gzip'd")
self.storage.save(name, content)
key = self.storage.bucket.get_key.return_value
key.set_metadata.assert_called_with('Content-Type', 'text/css')
key.set_contents_from_file.assert_called_with(
content,
headers={'Content-Type': 'text/css', 'Content-Encoding': 'gzip'},
policy=self.storage.default_acl,
rewind=True,
)

0 comments on commit 4b23315

Please sign in to comment.