summaryrefslogtreecommitdiff
path: root/tests/regressiontests/staticfiles_tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-11-17 15:36:26 +0000
committerJannis Leidel <jannis@leidel.info>2010-11-17 15:36:26 +0000
commit33d8fcde8a317184a627492f008a4eab9333ed88 (patch)
tree7c877854327c83aefdfaf00e727d26bd766e519e /tests/regressiontests/staticfiles_tests
parent9b45f6cd5444423693715cc2a04d91a0de75060b (diff)
Fixed #14693, #14709 -- Backwards incompatible change to rectify the confusion around the STATICFILES_URL and STATICFILES_ROOT settings.
* Two new global settings that will be used by -- **but are not limited to** -- the staticfiles app: STATIC_ROOT and STATIC_URL. * Moving the 'django.contrib.staticfiles.templatetags.staticfiles' template tag to the core ('django.templatetags.static') and renaming it to 'get_static_prefix'. * Moving the context processor 'django.contrib.staticfiles.context_processors.staticfiles' to the core ('django.core.context_processors.static') and renaming it to 'static'. * Paths in media definitions will use STATIC_URL as the prefix if the value is not None, and falls back to the previously used MEDIA_URL. Thanks again to the community for constructive criticism and Carl and Russ for sanity-inducing discussions on IRC. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/staticfiles_tests')
-rw-r--r--tests/regressiontests/staticfiles_tests/tests.py50
1 files changed, 15 insertions, 35 deletions
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py
index 0a6c060664..6cd581fff2 100644
--- a/tests/regressiontests/staticfiles_tests/tests.py
+++ b/tests/regressiontests/staticfiles_tests/tests.py
@@ -23,8 +23,8 @@ class StaticFilesTestCase(TestCase):
Test case with a couple utility assertions.
"""
def setUp(self):
- self.old_staticfiles_url = settings.STATICFILES_URL
- self.old_staticfiles_root = settings.STATICFILES_ROOT
+ self.old_static_url = settings.STATIC_URL
+ self.old_static_root = settings.STATIC_ROOT
self.old_staticfiles_dirs = settings.STATICFILES_DIRS
self.old_staticfiles_finders = settings.STATICFILES_FINDERS
self.old_media_root = settings.MEDIA_ROOT
@@ -40,8 +40,8 @@ class StaticFilesTestCase(TestCase):
settings.DEBUG = True
settings.MEDIA_ROOT = os.path.join(site_media, 'media')
settings.MEDIA_URL = '/media/'
- settings.STATICFILES_ROOT = os.path.join(site_media, 'static')
- settings.STATICFILES_URL = '/static/'
+ settings.STATIC_ROOT = os.path.join(site_media, 'static')
+ settings.STATIC_URL = '/static/'
settings.ADMIN_MEDIA_PREFIX = '/static/admin/'
settings.STATICFILES_DIRS = (
os.path.join(TEST_ROOT, 'project', 'documents'),
@@ -52,6 +52,7 @@ class StaticFilesTestCase(TestCase):
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
settings.INSTALLED_APPS = [
+ "django.contrib.staticfiles",
"regressiontests.staticfiles_tests",
]
@@ -65,8 +66,8 @@ class StaticFilesTestCase(TestCase):
settings.MEDIA_ROOT = self.old_media_root
settings.MEDIA_URL = self.old_media_url
settings.ADMIN_MEDIA_PREFIX = self.old_admin_media_prefix
- settings.STATICFILES_ROOT = self.old_staticfiles_root
- settings.STATICFILES_URL = self.old_staticfiles_url
+ settings.STATIC_ROOT = self.old_static_root
+ settings.STATIC_URL = self.old_static_url
settings.STATICFILES_DIRS = self.old_staticfiles_dirs
settings.STATICFILES_FINDERS = self.old_staticfiles_finders
settings.INSTALLED_APPS = self.old_installed_apps
@@ -91,13 +92,13 @@ class BuildStaticTestCase(StaticFilesTestCase):
def setUp(self):
super(BuildStaticTestCase, self).setUp()
self.old_staticfiles_storage = settings.STATICFILES_STORAGE
- self.old_root = settings.STATICFILES_ROOT
- settings.STATICFILES_ROOT = tempfile.mkdtemp()
+ self.old_root = settings.STATIC_ROOT
+ settings.STATIC_ROOT = tempfile.mkdtemp()
self.run_collectstatic()
def tearDown(self):
- shutil.rmtree(settings.STATICFILES_ROOT)
- settings.STATICFILES_ROOT = self.old_root
+ shutil.rmtree(settings.STATIC_ROOT)
+ settings.STATIC_ROOT = self.old_root
super(BuildStaticTestCase, self).tearDown()
def run_collectstatic(self, **kwargs):
@@ -106,7 +107,7 @@ class BuildStaticTestCase(StaticFilesTestCase):
def _get_file(self, filepath):
assert filepath, 'filepath is empty.'
- filepath = os.path.join(settings.STATICFILES_ROOT, filepath)
+ filepath = os.path.join(settings.STATIC_ROOT, filepath)
f = open(filepath)
try:
return f.read()
@@ -231,7 +232,7 @@ class TestBuildStaticDryRun(BuildStaticTestCase):
"""
With --dry-run, no files created in destination dir.
"""
- self.assertEquals(os.listdir(settings.STATICFILES_ROOT), [])
+ self.assertEquals(os.listdir(settings.STATIC_ROOT), [])
if sys.platform != 'win32':
@@ -251,7 +252,7 @@ if sys.platform != 'win32':
With ``--link``, symbolic links are created.
"""
- self.failUnless(os.path.islink(os.path.join(settings.STATICFILES_ROOT, 'test.txt')))
+ self.failUnless(os.path.islink(os.path.join(settings.STATIC_ROOT, 'test.txt')))
class TestServeStatic(StaticFilesTestCase):
@@ -262,7 +263,7 @@ class TestServeStatic(StaticFilesTestCase):
def _response(self, filepath):
return self.client.get(
- posixpath.join(settings.STATICFILES_URL, filepath))
+ posixpath.join(settings.STATIC_URL, filepath))
def assertFileContains(self, filepath, text):
self.assertContains(self._response(filepath), text)
@@ -372,24 +373,3 @@ class TestMiscFinder(TestCase):
finders.get_finder, "django.contrib.staticfiles.finders.FooBarFinder")
self.assertRaises(ImproperlyConfigured,
finders.get_finder, "foo.bar.FooBarFinder")
-
-
-class TemplateTagTest(TestCase):
- def test_get_staticfiles_prefix(self):
- """
- Test the get_staticfiles_prefix helper return the STATICFILES_URL setting.
- """
- self.assertEquals(Template(
- "{% load staticfiles %}"
- "{% get_staticfiles_prefix %}"
- ).render(Context()), settings.STATICFILES_URL)
-
- def test_get_staticfiles_prefix_with_as(self):
- """
- Test the get_staticfiles_prefix helper return the STATICFILES_URL setting.
- """
- self.assertEquals(Template(
- "{% load staticfiles %}"
- "{% get_staticfiles_prefix as staticfiles_prefix %}"
- "{{ staticfiles_prefix }}"
- ).render(Context()), settings.STATICFILES_URL)