Refs #15035 -- Corrected a bug and improved comments for a staticfiles test.

This commit is contained in:
Tim Graham 2017-01-03 19:22:19 -05:00
parent 1c12df4aa6
commit bff4abacad
2 changed files with 13 additions and 5 deletions

View File

@ -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):

View File

@ -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.")