diff options
| author | Tomasz Buchert | 2011-09-26 00:03:47 +0200 |
|---|---|---|
| committer | Tomasz Buchert | 2011-09-26 00:03:47 +0200 |
| commit | 01b5d65a1da80f3cc6120e53bba46e4da2ff44ca (patch) | |
| tree | 817fea74904193293f0e77136b169b3bae37a316 /tests | |
| parent | 5a3813d2bb4fb63d66b1b8a13edb8354b36a28b4 (diff) | |
| download | django-debug-toolbar-01b5d65a1da80f3cc6120e53bba46e4da2ff44ca.tar.bz2 | |
Issue 187: queries are captured and not executed when template panel is rendered.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tests.py b/tests/tests.py index 60620bb..5a52670 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,6 +1,7 @@ from debug_toolbar.middleware import DebugToolbarMiddleware from debug_toolbar.panels.sql import SQLDebugPanel from debug_toolbar.panels.request_vars import RequestVarsDebugPanel +from debug_toolbar.panels.template import TemplateDebugPanel from debug_toolbar.toolbar.loader import DebugToolbar from debug_toolbar.utils import get_name_from_obj from debug_toolbar.utils.tracking import pre_dispatch, post_dispatch, callbacks @@ -9,6 +10,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.http import HttpResponse from django.test import TestCase +from django.template import Template, Context from dingus import Dingus import thread @@ -194,6 +196,20 @@ class SQLPanelTestCase(BaseTestCase): self.assertTrue('duration' in query[1]) self.assertTrue('stacktrace' in query[1]) +class TemplatePanelTestCase(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.assertEquals(len(sql_panel._queries), 0) + ctx = template_panel.templates[0]['context'][0] + ctx = eval(ctx) # convert back to Python + self.assertEquals(ctx['queryset'], '<<queryset>>') + self.assertEquals(ctx['deep_queryset'], '<<contains queryset>>') + def module_func(*args, **kwargs): """Used by dispatch tests""" return 'blah' |
