Skip to content

Commit

Permalink
Move test for cache panel's disable_instrumentation function.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed Aug 28, 2021
1 parent 0f50eb9 commit ba6cc27
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ def test_low_level_cache_view(self):
self.client.get("/cached_low_level_view/")
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 3)

def test_cache_disable_instrumentation(self):
"""
Verify that middleware cache usages before and after
DebugToolbarMiddleware are not counted.
"""
self.assertIsNone(cache.set("UseCacheAfterToolbar.before", None))
self.assertIsNone(cache.set("UseCacheAfterToolbar.after", None))
self.client.get("/execute_sql/")
self.assertEqual(cache.get("UseCacheAfterToolbar.before"), 1)
self.assertEqual(cache.get("UseCacheAfterToolbar.after"), 1)
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 0)

def test_is_toolbar_request(self):
self.request.path = "/__debug__/render_panel/"
self.assertTrue(self.toolbar.is_toolbar_request(self.request))
Expand Down Expand Up @@ -384,7 +396,7 @@ def test_view_returns_template_response(self):
self.assertEqual(response.status_code, 200)

@override_settings(DEBUG_TOOLBAR_CONFIG={"DISABLE_PANELS": set()})
def test_incercept_redirects(self):
def test_intcercept_redirects(self):
response = self.client.get("/redirect/")
self.assertEqual(response.status_code, 200)
# Link to LOCATION header.
Expand Down Expand Up @@ -561,18 +573,6 @@ def test_django_cached_template_loader(self):
)
)

def test_cache_disable_instrumentation(self):
"""
Verify that middleware cache usages before and after
DebugToolbarMiddleware are not counted.
"""
self.assertIsNone(cache.set("UseCacheAfterToolbar.before", None))
self.assertIsNone(cache.set("UseCacheAfterToolbar.after", None))
self.get("/execute_sql/")
self.assertEqual(cache.get("UseCacheAfterToolbar.before"), 1)
self.assertEqual(cache.get("UseCacheAfterToolbar.after"), 1)
self.assertEqual(len(self.toolbar.get_panel_by_id("CachePanel").calls), 0)

def test_sql_action_and_go_back(self):
self.get("/execute_sql/")
sql_panel = self.selenium.find_element_by_id("SQLPanel")
Expand Down

0 comments on commit ba6cc27

Please sign in to comment.