aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/mixins.py
diff options
context:
space:
mode:
authorJamie Matthews2012-01-05 14:07:31 +0000
committerJamie Matthews2012-01-05 14:07:31 +0000
commit18535c7a387731b0e290ff59bb604bfd1a275ccc (patch)
tree0c0aeefd5c12b065f13ec3a58f8a79092de8c422 /djangorestframework/tests/mixins.py
parentb745d0c2f46b901ed7a6b8e92d4ea3faf2a47736 (diff)
downloaddjango-rest-framework-18535c7a387731b0e290ff59bb604bfd1a275ccc.tar.bz2
Preserve existing query params in PaginatorMixin
Previously, generation of next/previous links would discard any existing query parameters. This commit introduces a dependency on URLObject, which is used to intelligently parse and modify URLs to ensure existing params are preserved. Addresses issues #107
Diffstat (limited to 'djangorestframework/tests/mixins.py')
-rw-r--r--djangorestframework/tests/mixins.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/djangorestframework/tests/mixins.py b/djangorestframework/tests/mixins.py
index 3b814aa7..2913160d 100644
--- a/djangorestframework/tests/mixins.py
+++ b/djangorestframework/tests/mixins.py
@@ -237,3 +237,14 @@ class TestPagination(TestCase):
response = MockPaginatorView.as_view()(request)
content = json.loads(response.content)
self.assertEqual(response.status_code, status.NOT_FOUND)
+
+ def test_existing_query_parameters_are_preserved(self):
+ """ Tests that existing query parameters are preserved when
+ generating next/previous page links """
+ request = self.req.get('/paginator/?foo=bar&another=something')
+ response = MockPaginatorView.as_view()(request)
+ content = json.loads(response.content)
+ self.assertEqual(response.status_code, status.OK)
+ self.assertTrue('foo=bar' in content['next'])
+ self.assertTrue('another=something' in content['next'])
+ self.assertTrue('page=2' in content['next'])