summaryrefslogtreecommitdiffstats
path: root/tests/test_pages.py
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-09-14 12:46:56 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-09-16 07:51:21 (GMT)
commitb215a1bf3aa4ead49e56cf9ce98b8452a03a6e3a (patch)
treeaf216593f9a307db987590f9d4a053a61f417329 /tests/test_pages.py
parent6b33b55618d2289a0e19ebc59a396e1b220c52b7 (diff)
downloadcombo-b215a1bf3aa4ead49e56cf9ce98b8452a03a6e3a.zip
combo-b215a1bf3aa4ead49e56cf9ce98b8452a03a6e3a.tar.gz
combo-b215a1bf3aa4ead49e56cf9ce98b8452a03a6e3a.tar.bz2
misc: add methods to get next/previous page (#13038)
Diffstat (limited to 'tests/test_pages.py')
-rw-r--r--tests/test_pages.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_pages.py b/tests/test_pages.py
index 62c3658..5914ab2 100644
--- a/tests/test_pages.py
+++ b/tests/test_pages.py
@@ -161,3 +161,39 @@ def test_import_export_pages_with_links():
new_page_2 = Page.objects.all().order_by('order')[1]
assert CellBase.get_cells(page_id=new_page_1.id)[0].link_page_id == new_page_2.id
assert CellBase.get_cells(page_id=new_page_2.id)[0].link_page_id == new_page_1.id
+
+def test_next_previous():
+ Page.objects.all().delete()
+ page = Page()
+ page.slug = 'foo'
+ page.save()
+ page2 = Page()
+ page2.slug = 'bar'
+ page2.parent = page
+ page2.order = 1
+ page2.save()
+ page3 = Page()
+ page3.slug = 'baz'
+ page3.parent = page
+ page3.order = 2
+ page3.save()
+
+ assert page.get_next_page(None).id == page2.id
+ assert page.get_previous_page(None) is None
+
+ assert page2.get_next_page(None).id == page3.id
+ assert page2.get_previous_page(None).id == page.id
+
+ page2.public = False
+ page2.save()
+ assert page.get_next_page(None).id == page3.id
+ assert page3.get_previous_page(None).id == page.id
+
+ user1 = User(username='foo')
+ user1.save()
+ assert page.get_next_page(user1).id == page2.id
+ assert page3.get_previous_page(user1).id == page2.id
+
+ page3.public = False
+ page3.save()
+ assert page.get_next_page(None) is None