aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel2013-12-09 17:42:04 +0100
committerJannis Leidel2013-12-09 17:42:04 +0100
commite75309b712537f3ee53005bf6330057c9640be21 (patch)
treee83b9943c1cf4ee53754922629417468bfcaa153 /tests
parent2359b2e61d4f6018049042b3213a91af2b4db9fc (diff)
downloaddjango-debug-toolbar-e75309b712537f3ee53005bf6330057c9640be21.tar.bz2
Another pass over the staticfiles panel.
- adds some docstrings - adds some basic tests - adds the staticfiles panel to the default list of panels - fixed a pluralization bug in the template - refactored some things into own methods for easier testing
Diffstat (limited to 'tests')
-rw-r--r--tests/additional_static/base.css3
-rw-r--r--tests/panels/test_staticfiles.py30
-rw-r--r--tests/settings.py2
-rw-r--r--tests/tests.py1
4 files changed, 36 insertions, 0 deletions
diff --git a/tests/additional_static/base.css b/tests/additional_static/base.css
new file mode 100644
index 0000000..8d7d127
--- /dev/null
+++ b/tests/additional_static/base.css
@@ -0,0 +1,3 @@
+body {
+ color: green;
+} \ No newline at end of file
diff --git a/tests/panels/test_staticfiles.py b/tests/panels/test_staticfiles.py
new file mode 100644
index 0000000..7f68205
--- /dev/null
+++ b/tests/panels/test_staticfiles.py
@@ -0,0 +1,30 @@
+# coding: utf-8
+
+from __future__ import absolute_import, unicode_literals
+
+from django.conf import settings
+from django.contrib.staticfiles.templatetags import staticfiles
+from django.template import Context, RequestContext, Template
+
+from ..base import BaseTestCase
+
+
+class StaticFilesPanelTestCase(BaseTestCase):
+
+ def setUp(self):
+ super(StaticFilesPanelTestCase, self).setUp()
+ self.panel = self.toolbar.get_panel_by_id('StaticFilesPanel')
+
+ def test_default_case(self):
+ self.panel.process_request(self.request)
+ self.panel.process_response(self.request, self.response)
+ self.assertIn('django.contrib.staticfiles.finders.'
+ 'AppDirectoriesFinder (87 files)', self.panel.content)
+ self.assertIn('django.contrib.staticfiles.finders.'
+ 'FileSystemFinder (1 file)', self.panel.content)
+ self.assertEqual(self.panel.num_used, 0)
+ self.assertEqual(self.panel.num_found, 88)
+ self.assertEqual(self.panel.get_staticfiles_apps(),
+ ['django.contrib.admin', 'debug_toolbar'])
+ self.assertEqual(self.panel.get_staticfiles_dirs(),
+ settings.STATICFILES_DIRS)
diff --git a/tests/settings.py b/tests/settings.py
index 24e0cd4..9ff9fb6 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -40,6 +40,8 @@ ROOT_URLCONF = 'tests.urls'
STATIC_URL = '/static/'
+STATICFILES_DIRS = [os.path.join(BASE_DIR, 'tests', 'additional_static')]
+
# Cache and database
diff --git a/tests/tests.py b/tests/tests.py
index 1818fe7..ca77f5b 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -8,6 +8,7 @@ if django.VERSION[:2] < (1, 6): # unittest-style discovery isn't available
from .panels.test_redirects import * # noqa
from .panels.test_request import * # noqa
from .panels.test_sql import * # noqa
+ from .panels.test_staticfiles import * # noqa
from .panels.test_template import * # noqa
from .test_integration import * # noqa
from .test_utils import * # noqa