InfinitePaginator (from Pownce) with tests! The InfinitePaginator does not count...
[django-pagination.git] / pagination / tests.py
index 837e55c..c0a4a6c 100644 (file)
 # ENDWARNING
 
 >>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
-u'\\n<div class="pagination">...
+u'\\n\\n<div class="pagination">...
 >>>
 >>> t = Template("{% load pagination_tags %}{% autopaginate var %}{% paginate %}")
 >>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
-u'\\n<div class="pagination">...
+u'\\n\\n<div class="pagination">...
+>>> t = Template("{% load pagination_tags %}{% autopaginate var 20 %}{% paginate %}")
+>>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
+u'\\n\\n<div class="pagination">...
+>>> t = Template("{% load pagination_tags %}{% autopaginate var by %}{% paginate %}")
+>>> t.render(Context({'var': range(21), 'by': 20, 'request': RequestProxy()}))
+u'\\n\\n<div class="pagination">...
+>>> t = Template("{% load pagination_tags %}{% autopaginate var by as foo %}{{ foo }}")
+>>> t.render(Context({'var': range(21), 'by': 20, 'request': RequestProxy()}))
+u'[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]'
 >>>
+
+# Testing InfinitePaginator
+
+>>> from paginator import InfinitePaginator
+>>> InfinitePaginator
+<class 'pagination.paginator.InfinitePaginator'>
+>>> p = InfinitePaginator(range(20), 2, link_template='/bacon/page/%d')
+>>> p.validate_number(2)
+2
+>>> p.orphans
+0
+>>> p3 = p.page(3)
+>>> p3
+<Page 3>
+>>> p3.end_index()
+6
+>>> p3.has_next()
+True
+>>> p3.has_previous()
+True
+>>> p.page(10).has_next()
+False
+>>> p.page(1).has_previous()
+False
+>>> p3.next_link()
+'/bacon/page/4'
+>>> p3.previous_link()
+'/bacon/page/2'
 """
\ No newline at end of file