summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-04-10 20:05:46 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-04-10 20:05:46 +0000
commit28e5b665189548557993b522e3bd7adeed3f62ea (patch)
tree647befaf984a5d36833afce8c7269c5da102e5c4 /tests
parent916d705538045529709c83033ef22f9b3895a462 (diff)
Fixed #18087 -- Prevented date-based generic views from loading entire tables in memory when pagination is enabled.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17893 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/generic_views/dates.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index 652f66b7f1..9de817acc2 100644
--- a/tests/regressiontests/generic_views/dates.py
+++ b/tests/regressiontests/generic_views/dates.py
@@ -78,6 +78,15 @@ class ArchiveIndexViewTests(TestCase):
self.assertEqual(res.context['page_obj'].number, 2)
self.assertEqual(list(res.context['latest']), list(Book.objects.all()[10:20]))
+ def test_paginated_archive_view_does_not_load_entire_table(self):
+ # Regression test for #18087
+ self._make_books(20, base_date=datetime.date.today())
+ # 1 query for years list + 1 query for books
+ with self.assertNumQueries(2):
+ self.client.get('/dates/books/')
+ # same as above + 1 query to test if books exist
+ with self.assertNumQueries(3):
+ self.client.get('/dates/books/paginated/')
class YearArchiveViewTests(TestCase):
fixtures = ['generic-views-test-data.json']