8
8
from debug_toolbar .store import get_store
9
9
from debug_toolbar .toolbar import DebugToolbar
10
10
11
- from .. import settings as test_settings
12
11
from ..base import BaseTestCase , IntegrationTestCase
13
12
14
13
rf = RequestFactory ()
@@ -110,14 +109,17 @@ def test_history_headers(self):
110
109
request_id = list (get_store ().request_ids ())[0 ]
111
110
self .assertEqual (response .headers ["djdt-request-id" ], request_id )
112
111
113
- @override_settings (
114
- DEBUG_TOOLBAR_CONFIG = {"OBSERVE_REQUEST_CALLBACK" : lambda request : False }
115
- )
116
112
def test_history_headers_unobserved (self ):
117
113
"""Validate the headers aren't injected from the history panel."""
114
+ with self .settings (
115
+ DEBUG_TOOLBAR_CONFIG = {"OBSERVE_REQUEST_CALLBACK" : lambda request : False }
116
+ ):
117
+ DebugToolbar .get_observe_request .cache_clear ()
118
+ response = self .client .get ("/json_view/" )
119
+ self .assertNotIn ("djdt-request-id" , response .headers )
120
+ # Clear it again to avoid conflicting with another test
121
+ # Specifically, DebugToolbarLiveTestCase.test_ajax_refresh
118
122
DebugToolbar .get_observe_request .cache_clear ()
119
- response = self .client .get ("/json_view/" )
120
- self .assertNotIn ("djdt-request-id" , response .headers )
121
123
122
124
def test_history_sidebar (self ):
123
125
"""Validate the history sidebar view."""
@@ -145,7 +147,9 @@ def test_history_sidebar_includes_history(self):
145
147
panel_keys ,
146
148
)
147
149
148
- @override_settings (DEBUG_TOOLBAR_CONFIG = {"RENDER_PANELS" : False })
150
+ @override_settings (
151
+ DEBUG_TOOLBAR_CONFIG = {"RENDER_PANELS" : False , "RESULTS_CACHE_SIZE" : 1 }
152
+ )
149
153
def test_history_sidebar_expired_request_id (self ):
150
154
"""Validate the history sidebar view."""
151
155
self .client .get ("/json_view/" )
@@ -158,8 +162,7 @@ def test_history_sidebar_expired_request_id(self):
158
162
self .PANEL_KEYS ,
159
163
)
160
164
# Make enough requests to unset the original
161
- for _i in range (test_settings .DEBUG_TOOLBAR_CONFIG ["RESULTS_CACHE_SIZE" ]):
162
- self .client .get ("/json_view/" )
165
+ self .client .get ("/json_view/" )
163
166
164
167
# Querying old request_id should return in empty response
165
168
data = {"request_id" : request_id , "exclude_history" : True }
0 commit comments