Add test for image pagination preserving URL params

pull/2978/merge
Matt Westcott 2016-10-03 18:28:20 +01:00
rodzic 51bcecf368
commit 561f0a7cff
1 zmienionych plików z 27 dodań i 0 usunięć

Wyświetl plik

@ -49,6 +49,33 @@ class TestImageIndexView(TestCase, WagtailTestUtils):
response = self.get({'p': page})
self.assertEqual(response.status_code, 200)
def test_pagination_preserves_other_params(self):
root_collection = Collection.get_first_root_node()
evil_plans_collection = root_collection.add_child(name="Evil plans")
for i in range(1, 50):
self.image = Image.objects.create(
title="Test image %i" % i,
file=get_test_image_file(),
collection=evil_plans_collection
)
response = self.get({'collection_id': evil_plans_collection.id, 'p': 2})
self.assertEqual(response.status_code, 200)
response_body = response.content.decode('utf8')
# prev link should exist and include collection_id
self.assertTrue(
("?p=1&collection_id=%i" % evil_plans_collection.id) in response_body
or ("?collection_id=%i&p=1" % evil_plans_collection.id) in response_body
)
# next link should exist and include collection_id
self.assertTrue(
("?p=3&collection_id=%i" % evil_plans_collection.id) in response_body
or ("?collection_id=%i&p=3" % evil_plans_collection.id) in response_body
)
def test_ordering(self):
orderings = ['title', '-created_at']
for ordering in orderings: