summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2011-01-08 13:15:44 +0000
committerAndrew Godwin <andrew@aeracode.org>2011-01-08 13:15:44 +0000
commit32a344dfe297a16087765d2f4fb2e1398dc21ac8 (patch)
treefa53d519619d2b36dfbffa6243211bb2ba9d6097 /tests
parent19ab52f77fef0edb1e4101e7f8acaa093d3ca16c (diff)
Fixed inconsistency in ListView's pagination (short datasets should also trigger a pagination, but with a single possible page)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15155 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/generic_views/list.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index 7414c62d3a..de7302048b 100644
--- a/tests/regressiontests/generic_views/list.py
+++ b/tests/regressiontests/generic_views/list.py
@@ -38,14 +38,15 @@ class ListViewTests(TestCase):
self.assertEqual(list(res.context['authors'])[-1].name, 'Author 29')
def test_paginated_queryset_shortdata(self):
+ # Test that short datasets ALSO result in a paginated view.
res = self.client.get('/list/authors/paginated/')
self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, 'generic_views/author_list.html')
self.assertEqual(list(res.context['object_list']), list(Author.objects.all()))
self.assertIs(res.context['authors'], res.context['object_list'])
- self.assertIsNone(res.context['paginator'])
- self.assertIsNone(res.context['page_obj'])
- self.assertFalse(res.context['is_paginated'])
+ self.assertEqual(res.context['page_obj'].number, 1)
+ self.assertEqual(res.context['paginator'].num_pages, 1)
+ self.assertTrue(res.context['is_paginated'])
def test_paginated_get_page_by_query_string(self):
self._make_authors(100)
@@ -90,7 +91,7 @@ class ListViewTests(TestCase):
self._make_authors(7)
res = self.client.get('/list/authors/paginated/custom_class/')
self.assertEqual(res.status_code, 200)
- self.assertIsNone(res.context['paginator'])
+ self.assertEqual(res.context['paginator'].num_pages, 1)
# Custom pagination allows for 2 orphans on a page size of 5
self.assertEqual(len(res.context['object_list']), 7)