Skip to content

Commit

Permalink
Add test for old style, debug_toolbar.urls usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed Dec 9, 2021
1 parent 7d0962c commit 2830367
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ def get_response(request):
self.assertContains(response, "</div>\n</body>")

def test_cache_page(self):
# Clear the cache before testing the views. Other tests that use cached_view
# may run earlier and cause fewer cache calls.
cache.clear()
self.client.get("/cached_view/")
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 3)
self.client.get("/cached_view/")
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 5)

@override_settings(ROOT_URLCONF="tests.urls_use_package_urls")
def test_include_package_urls(self):
"""Test urlsconf that uses the debug_toolbar.urls in the include call"""
# Clear the cache before testing the views. Other tests that use cached_view
# may run earlier and cause fewer cache calls.
cache.clear()
self.client.get("/cached_view/")
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 3)
self.client.get("/cached_view/")
Expand Down
11 changes: 11 additions & 0 deletions tests/urls_use_package_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""urls.py to test using debug_toolbar.urls in include"""
from django.urls import include, path

import debug_toolbar

from . import views

urlpatterns = [
path("cached_view/", views.cached_view),
path("__debug__/", include(debug_toolbar.urls)),
]

0 comments on commit 2830367

Please sign in to comment.