Skip to content

Commit

Permalink
Fix 1.10 compat: queued storage should not mask or use deprecated met…
Browse files Browse the repository at this point in the history
…hods in newer ones
  • Loading branch information
ashwoods committed Aug 20, 2017
1 parent dce2cd3 commit 7e1f9e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions queued_storage/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def save(self, name, content, max_length=None):
# systems and save locally.
name = self.get_available_name(name)
try:
name = self.local.save(name, content, max_length=None)
name = self.local.save(name, content, max_length=max_length)
except TypeError:
# Django < 1.10
name = self.local.save(name, content)
Expand Down Expand Up @@ -355,7 +355,7 @@ def get_accessed_time(self, name):
:type name: str
:rtype: :class:`~python:datetime.datetime`
"""
return self.get_storage(name).accessed_time(name)
return self.get_storage(name).get_accessed_time(name)

def get_created_time(self, name):
"""
Expand All @@ -368,7 +368,7 @@ def get_created_time(self, name):
:rtype: :class:`~python:datetime.datetime`
"""

return self.get_storage(name).created_time(name)
return self.get_storage(name).get_created_time(name)

def get_modified_time(self, name):
"""
Expand All @@ -381,7 +381,7 @@ def get_modified_time(self, name):
:rtype: :class:`~python:datetime.datetime`
"""

return self.get_storage(name).modified_time(name)
return self.get_storage(name).get_modified_time(name)

def generate_filename(self, filename):
return self.get_storage(filename).generate_filename(filename)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from os import path
from datetime import datetime
from packaging import version
from packaging.specifiers import SpecifierSet

import django
from django.core.files.base import File
Expand Down Expand Up @@ -145,7 +146,7 @@ def test_storage_celery_save(self):
os.stat(self.test_file_path).st_size)
self.assertEqual(storage.url(self.test_file_name), self.test_file_name)

if version.parse(DJANGO_VERSION) <= version.parse('2'):
if version.parse(DJANGO_VERSION) in SpecifierSet("<=2.0"):
self.assertIsInstance(storage.accessed_time(subdir_path), datetime)
self.assertIsInstance(storage.created_time(subdir_path), datetime)
self.assertIsInstance(storage.modified_time(subdir_path), datetime)
Expand Down

0 comments on commit 7e1f9e6

Please sign in to comment.