Skip to content

Commit 571b240

Browse files
committed
Order History panels requests descending chronologically.
1 parent 3c081d6 commit 571b240

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

debug_toolbar/panels/history/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def history_refresh(request):
4343

4444
if form.is_valid():
4545
requests = []
46-
# Convert to list to handle mutations happenening in parallel
47-
for id, toolbar in list(DebugToolbar._store.items())[::-1]:
46+
# Convert to list to handle mutations happening in parallel
47+
for id, toolbar in list(DebugToolbar._store.items()):
4848
requests.append(
4949
{
5050
"id": id,

tests/panels/test_history.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,24 @@ def test_history_sidebar_expired_store_id(self):
160160

161161
def test_history_refresh(self):
162162
"""Verify refresh history response has request variables."""
163-
data = {"foo": "bar"}
164-
self.client.get("/json_view/", data, content_type="application/json")
165-
data = {"store_id": "foo"}
166-
response = self.client.get(reverse("djdt:history_refresh"), data=data)
163+
self.client.get("/json_view/", {"foo": "bar"}, content_type="application/json")
164+
self.client.get(
165+
"/json_view/", {"spam": "eggs"}, content_type="application/json"
166+
)
167+
168+
response = self.client.get(
169+
reverse("djdt:history_refresh"), data={"store_id": "foo"}
170+
)
167171
self.assertEqual(response.status_code, 200)
168172
data = response.json()
169-
self.assertEqual(len(data["requests"]), 1)
173+
self.assertEqual(len(data["requests"]), 2)
170174

171-
store_id = list(DebugToolbar._store)[0]
172-
self.assertIn(html.escape(store_id), data["requests"][0]["content"])
175+
store_ids = list(DebugToolbar._store)
176+
self.assertIn(html.escape(store_ids[0]), data["requests"][0]["content"])
177+
self.assertIn(html.escape(store_ids[1]), data["requests"][1]["content"])
173178

174179
for val in ["foo", "bar"]:
175180
self.assertIn(val, data["requests"][0]["content"])
181+
182+
for val in ["spam", "eggs"]:
183+
self.assertIn(val, data["requests"][1]["content"])

0 commit comments

Comments
 (0)