From 7e1f9e677e141a613fe706f47574a2c605787852 Mon Sep 17 00:00:00 2001 From: Ashley Camba Garrido Date: Sun, 20 Aug 2017 15:09:23 +0200 Subject: [PATCH] Fix 1.10 compat: queued storage should not mask or use deprecated methods in newer ones --- queued_storage/backends.py | 8 ++++---- tests/test_storages.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/queued_storage/backends.py b/queued_storage/backends.py index 8bbd483..40bfeb4 100644 --- a/queued_storage/backends.py +++ b/queued_storage/backends.py @@ -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) @@ -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): """ @@ -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): """ @@ -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) diff --git a/tests/test_storages.py b/tests/test_storages.py index 93d8608..b215a35 100644 --- a/tests/test_storages.py +++ b/tests/test_storages.py @@ -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 @@ -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)