From bff4abacad48eba715be64d7b15582d15bdc1fca Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 3 Jan 2017 19:22:19 -0500 Subject: [PATCH] Refs #15035 -- Corrected a bug and improved comments for a staticfiles test. --- tests/staticfiles_tests/storage.py | 5 +++-- tests/staticfiles_tests/test_management.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py index 467217ae53..12eb032d8e 100644 --- a/tests/staticfiles_tests/storage.py +++ b/tests/staticfiles_tests/storage.py @@ -10,7 +10,8 @@ from django.utils import timezone class DummyStorage(storage.Storage): """ - A storage class that implements get_modified_time(). + A storage class that implements get_modified_time() but raises + NotImplementedError for path(). """ def _save(self, name, content): return 'dummy' @@ -22,7 +23,7 @@ class DummyStorage(storage.Storage): pass def get_modified_time(self, name): - return datetime.datetime(1970, 1, 1, tzinfo=timezone.utc) + return datetime(1970, 1, 1, tzinfo=timezone.utc) class PathNotImplementedStorage(storage.Storage): diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py index d4d5064b74..c3075fb712 100644 --- a/tests/staticfiles_tests/test_management.py +++ b/tests/staticfiles_tests/test_management.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import codecs +import datetime import os import shutil import tempfile @@ -15,7 +16,7 @@ from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command from django.test import mock, override_settings from django.test.utils import extend_sys_path -from django.utils import six +from django.utils import six, timezone from django.utils._os import symlinks_supported from django.utils.encoding import force_text from django.utils.functional import empty @@ -387,9 +388,15 @@ class TestCollectionOverwriteWarning(CollectionTestCase): @override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.DummyStorage') class TestCollectionNonLocalStorage(TestNoFilesCreated, CollectionTestCase): """ - Tests for #15035 + Tests for a Storage that implements get_modified_time() but not path() + (#15035). """ - pass + def test_storage_properties(self): + # Properties of the Storage as described in the ticket. + storage = DummyStorage() + self.assertEqual(storage.get_modified_time('name'), datetime.datetime(1970, 1, 1, tzinfo=timezone.utc)) + with self.assertRaisesMessage(NotImplementedError, "This backend doesn't support absolute paths."): + storage.path('name') @unittest.skipUnless(symlinks_supported(), "Must be able to symlink to run this test.")