aboutsummaryrefslogtreecommitdiffstats
path: root/tests/panels/test_template.py
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-01 21:51:37 +0100
committerAymeric Augustin2013-11-01 21:51:37 +0100
commit96f1cb4b0d4b10903502e917ddaa460bc05f5ca3 (patch)
tree2d72e912b523f498f7e1c82aad362d5e6a58f396 /tests/panels/test_template.py
parentf69f51f7abf25aaf5282c953475e8975694f41c1 (diff)
downloaddjango-debug-toolbar-96f1cb4b0d4b10903502e917ddaa460bc05f5ca3.tar.bz2
Split tests across several modules.
Fix #426.
Diffstat (limited to 'tests/panels/test_template.py')
-rw-r--r--tests/panels/test_template.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/panels/test_template.py b/tests/panels/test_template.py
new file mode 100644
index 0000000..4e30a73
--- /dev/null
+++ b/tests/panels/test_template.py
@@ -0,0 +1,31 @@
+from __future__ import unicode_literals
+
+import django
+from django.contrib.auth.models import User
+from django.template import Template, Context
+
+from debug_toolbar.panels.template import TemplateDebugPanel
+from debug_toolbar.panels.sql import SQLDebugPanel
+
+from ..base import BaseTestCase
+
+
+class TemplateDebugPanelTestCase(BaseTestCase):
+
+ def test_queryset_hook(self):
+ template_panel = self.toolbar.get_panel(TemplateDebugPanel)
+ sql_panel = self.toolbar.get_panel(SQLDebugPanel)
+ t = Template("No context variables here!")
+ c = Context({
+ 'queryset': User.objects.all(),
+ 'deep_queryset': {
+ 'queryset': User.objects.all(),
+ }
+ })
+ t.render(c)
+ # ensure the query was NOT logged
+ self.assertEqual(len(sql_panel._queries), 0)
+ base_ctx_idx = 1 if django.VERSION[:2] >= (1, 5) else 0
+ ctx = template_panel.templates[0]['context'][base_ctx_idx]
+ self.assertIn('<<queryset of auth.User>>', ctx)
+ self.assertIn('<<triggers database query>>', ctx)