/usr/share/pyshared/djapian/tests/pagination.py is in python-django-djapian 2.3.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from django.core.paginator import Paginator
from djapian.tests.utils import BaseTestCase, Entry, Person
class ResultSetPaginationTest(BaseTestCase):
num_entries = 100
per_page = 10
num_pages = num_entries / per_page
def setUp(self):
p = Person.objects.create(name="Alex")
for i in range(self.num_entries):
Entry.objects.create(
author=p,
title="Entry with number %s" % i,
text="foobar " * i
)
Entry.indexer.update()
self.result = Entry.indexer.search("title:number")
def test_pagintion(self):
paginator = Paginator(self.result, self.per_page)
self.assertEqual(paginator.num_pages, self.num_pages)
page = paginator.page(5)
|