Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change Google Storage setting to gzip from is_gzipped #60

Merged
merged 1 commit into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)