summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Christie <tom@tomchristie.com>2012-10-25 13:19:53 +0100
committerTom Christie <tom@tomchristie.com>2012-10-25 13:19:53 +0100
commitf824a951776db86c04aaefc1e7c1c12ffb84c798 (patch)
tree0adfd2ca4264bbb82d89624722e9e56c08b77903
parent502be865c68635d5c31fa3fa58162b48412153ad (diff)
Test for `ListView.page_kwarg`
-rw-r--r--tests/regressiontests/generic_views/list.py10
-rw-r--r--tests/regressiontests/generic_views/urls.py2
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index 14dc1d725d..d267824b84 100644
--- a/tests/regressiontests/generic_views/list.py
+++ b/tests/regressiontests/generic_views/list.py
@@ -99,6 +99,16 @@ class ListViewTests(TestCase):
# Custom pagination allows for 2 orphans on a page size of 5
self.assertEqual(len(res.context['object_list']), 7)
+ def test_paginated_custom_page_kwarg(self):
+ self._make_authors(100)
+ res = self.client.get('/list/authors/paginated/custom_page_kwarg/', {'pagina': '2'})
+ self.assertEqual(res.status_code, 200)
+ self.assertTemplateUsed(res, 'generic_views/author_list.html')
+ self.assertEqual(len(res.context['object_list']), 30)
+ self.assertIs(res.context['author_list'], res.context['object_list'])
+ self.assertEqual(res.context['author_list'][0].name, 'Author 30')
+ self.assertEqual(res.context['page_obj'].number, 2)
+
def test_paginated_custom_paginator_constructor(self):
self._make_authors(7)
res = self.client.get('/list/authors/paginated/custom_constructor/')
diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py
index c72bfecb65..a212b830a5 100644
--- a/tests/regressiontests/generic_views/urls.py
+++ b/tests/regressiontests/generic_views/urls.py
@@ -149,6 +149,8 @@ urlpatterns = patterns('',
views.AuthorList.as_view(queryset=None)),
(r'^list/authors/paginated/custom_class/$',
views.AuthorList.as_view(paginate_by=5, paginator_class=views.CustomPaginator)),
+ (r'^list/authors/paginated/custom_page_kwarg/$',
+ views.AuthorList.as_view(paginate_by=30, page_kwarg='pagina')),
(r'^list/authors/paginated/custom_constructor/$',
views.AuthorListCustomPaginator.as_view()),