diff options
| author | Moritz Sichert <moritz.sichert@googlemail.com> | 2015-07-01 13:43:25 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-01 09:41:27 -0400 |
| commit | b35b43dff81d46e930ffa1e05eb50968b8557102 (patch) | |
| tree | 7b4bd08113c07e74a6834247a09fd775828a3639 /tests/staticfiles_tests/test_views.py | |
| parent | 3d7a713156c39ee197ee447130b3e6e078acbadc (diff) | |
Fixed #24982 -- Split staticfiles tests into multiple files
Diffstat (limited to 'tests/staticfiles_tests/test_views.py')
| -rw-r--r-- | tests/staticfiles_tests/test_views.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/test_views.py b/tests/staticfiles_tests/test_views.py new file mode 100644 index 0000000000..e9b484b3f7 --- /dev/null +++ b/tests/staticfiles_tests/test_views.py @@ -0,0 +1,46 @@ +from __future__ import unicode_literals + +import posixpath + +from django.conf import settings +from django.test import override_settings + +from .cases import StaticFilesTestCase, TestDefaults + + +@override_settings(ROOT_URLCONF='staticfiles_tests.urls.default') +class TestServeStatic(StaticFilesTestCase): + """ + Test static asset serving view. + """ + def _response(self, filepath): + return self.client.get( + posixpath.join(settings.STATIC_URL, filepath)) + + def assertFileContains(self, filepath, text): + self.assertContains(self._response(filepath), text) + + def assertFileNotFound(self, filepath): + self.assertEqual(self._response(filepath).status_code, 404) + + +@override_settings(DEBUG=False) +class TestServeDisabled(TestServeStatic): + """ + Test serving static files disabled when DEBUG is False. + """ + def test_disabled_serving(self): + self.assertFileNotFound('test.txt') + + +class TestServeStaticWithDefaultURL(TestServeStatic, TestDefaults): + """ + Test static asset serving view with manually configured URLconf. + """ + + +@override_settings(ROOT_URLCONF='staticfiles_tests.urls.helper') +class TestServeStaticWithURLHelper(TestServeStatic, TestDefaults): + """ + Test static asset serving view with staticfiles_urlpatterns helper. + """ |
