diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-01-08 10:03:27 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-01-08 10:03:27 +0000 |
| commit | 19ab52f77fef0edb1e4101e7f8acaa093d3ca16c (patch) | |
| tree | a6d04906a3dbbed7a652eff436409ffbb4a6a96a /tests/regressiontests | |
| parent | a3894945b647c3e07acdd35af1104739a93938a2 (diff) | |
Fixed #15035 -- Fixed collectstatic management command to work with non-local storage backends correctly. Also refactored a bit code smell.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15154 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/storage.py | 19 | ||||
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/tests.py | 30 |
2 files changed, 42 insertions, 7 deletions
diff --git a/tests/regressiontests/staticfiles_tests/storage.py b/tests/regressiontests/staticfiles_tests/storage.py new file mode 100644 index 0000000000..cfe1e13bdb --- /dev/null +++ b/tests/regressiontests/staticfiles_tests/storage.py @@ -0,0 +1,19 @@ +from datetime import datetime +from django.core.files import storage + +class DummyStorage(storage.Storage): + """ + A storage class that does implement modified_time() but raises + NotImplementedError when calling + """ + def _save(self, name, content): + return 'dummy' + + def delete(self, name): + pass + + def exists(self, name): + pass + + def modified_time(self, name): + return datetime.date(1970, 1, 1) diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py index cf532bb414..62286c7267 100644 --- a/tests/regressiontests/staticfiles_tests/tests.py +++ b/tests/regressiontests/staticfiles_tests/tests.py @@ -92,7 +92,6 @@ class BuildStaticTestCase(StaticFilesTestCase): """ def setUp(self): super(BuildStaticTestCase, self).setUp() - self.old_staticfiles_storage = settings.STATICFILES_STORAGE self.old_root = settings.STATIC_ROOT settings.STATIC_ROOT = tempfile.mkdtemp() self.run_collectstatic() @@ -220,18 +219,35 @@ class TestBuildStaticExcludeNoDefaultIgnore(BuildStaticTestCase, TestDefaults): self.assertFileContains('test/CVS', 'should be ignored') -class TestBuildStaticDryRun(BuildStaticTestCase): +class TestNoFilesCreated(object): + + def test_no_files_created(self): + """ + Make sure no files were create in the destination directory. + """ + self.assertEquals(os.listdir(settings.STATIC_ROOT), []) + + +class TestBuildStaticDryRun(BuildStaticTestCase, TestNoFilesCreated): """ Test ``--dry-run`` option for ``collectstatic`` management command. """ def run_collectstatic(self): super(TestBuildStaticDryRun, self).run_collectstatic(dry_run=True) - def test_no_files_created(self): - """ - With --dry-run, no files created in destination dir. - """ - self.assertEquals(os.listdir(settings.STATIC_ROOT), []) + +class TestBuildStaticNonLocalStorage(BuildStaticTestCase, TestNoFilesCreated): + """ + Tests for #15035 + """ + def setUp(self): + self.old_staticfiles_storage = settings.STATICFILES_STORAGE + settings.STATICFILES_STORAGE = 'regressiontests.staticfiles_tests.storage.DummyStorage' + super(TestBuildStaticNonLocalStorage, self).setUp() + + def tearDown(self): + super(TestBuildStaticNonLocalStorage, self).tearDown() + settings.STATICFILES_STORAGE = self.old_staticfiles_storage if sys.platform != 'win32': |
