55
66from debug_toolbar .forms import SignedDataForm
77from debug_toolbar .store import store
8+ from debug_toolbar .toolbar import stats_only_toolbar
89
910from ..base import BaseTestCase , IntegrationTestCase
1011
@@ -83,14 +84,14 @@ class HistoryViewsTestCase(IntegrationTestCase):
8384
8485 def test_history_panel_integration_content (self ):
8586 """Verify the history panel's content renders properly.."""
86- self .assertEqual (len (store .all ()), 0 )
87+ self .assertEqual (len (store .ids ()), 0 )
8788
8889 data = {"foo" : "bar" }
8990 self .client .get ("/json_view/" , data , content_type = "application/json" )
9091
9192 # Check the history panel's stats to verify the toolbar rendered properly.
92- self .assertEqual (len (store .all ()), 1 )
93- toolbar = list (store .all ()) [0 ][ 1 ]
93+ self .assertEqual (len (store .ids ()), 1 )
94+ toolbar = stats_only_toolbar (store .ids () [0 ])
9495 content = toolbar .get_panel_by_id ("HistoryPanel" ).content
9596 self .assertIn ("bar" , content )
9697
@@ -99,21 +100,34 @@ def test_history_sidebar_invalid(self):
99100 self .assertEqual (response .status_code , 400 )
100101
101102 self .client .get ("/json_view/" )
102- store_id = list ( store .all ())[ 0 ] [0 ]
103+ store_id = store .ids () [0 ]
103104 data = {"signed" : SignedDataForm .sign ({"store_id" : store_id }) + "invalid" }
104105 response = self .client .get (reverse ("djdt:history_sidebar" ), data = data )
105106 self .assertEqual (response .status_code , 400 )
106107
107108 def test_history_sidebar_hash (self ):
108109 """Validate the hashing mechanism."""
109110 self .client .get ("/json_view/" )
110- store_id = list ( store .all ())[ 0 ] [0 ]
111+ store_id = store .ids () [0 ]
111112 data = {"signed" : SignedDataForm .sign ({"store_id" : store_id })}
112113 response = self .client .get (reverse ("djdt:history_sidebar" ), data = data )
113114 self .assertEqual (response .status_code , 200 )
114115 self .assertEqual (
115- set (response .json ()),
116- self .PANEL_KEYS ,
116+ list (response .json ().keys ()),
117+ [
118+ "VersionsPanel" ,
119+ "TimerPanel" ,
120+ "SettingsPanel" ,
121+ "HeadersPanel" ,
122+ "RequestPanel" ,
123+ "SQLPanel" ,
124+ "StaticFilesPanel" ,
125+ "TemplatesPanel" ,
126+ "CachePanel" ,
127+ "SignalsPanel" ,
128+ "LoggingPanel" ,
129+ "ProfilingPanel" ,
130+ ],
117131 )
118132
119133 @override_settings (
@@ -122,7 +136,7 @@ def test_history_sidebar_hash(self):
122136 def test_history_sidebar_expired_store_id (self ):
123137 """Validate the history sidebar view."""
124138 self .client .get ("/json_view/" )
125- store_id = list (store .all ())[ 0 ] [0 ]
139+ store_id = list (store .ids ())[0 ]
126140 data = {"signed" : SignedDataForm .sign ({"store_id" : store_id })}
127141 response = self .client .get (reverse ("djdt:history_sidebar" ), data = data )
128142 self .assertEqual (response .status_code , 200 )
@@ -142,7 +156,7 @@ def test_history_sidebar_expired_store_id(self):
142156 )
143157
144158 # Querying with latest store_id
145- latest_store_id = list ( store .all ()) [- 1 ][ 0 ]
159+ latest_store_id = store .ids () [- 1 ]
146160 self .assertNotEqual (latest_store_id , store_id )
147161 data = {"signed" : SignedDataForm .sign ({"store_id" : latest_store_id })}
148162 response = self .client .get (reverse ("djdt:history_sidebar" ), data = data )
@@ -170,7 +184,7 @@ def test_history_refresh(self):
170184 data = response .json ()
171185 self .assertEqual (len (data ["requests" ]), 1 )
172186
173- store_id = list ( store .all ())[ 0 ] [0 ]
187+ store_id = store .ids () [0 ]
174188 signature = SignedDataForm .sign ({"store_id" : store_id })
175189 self .assertIn (html .escape (signature ), data ["requests" ][0 ]["content" ])
176190
0 commit comments