<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from django . test import TestCase <EOL> from el_pagination import paginators <EOL> class PaginatorTestMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . items = list ( range ( <NUM_LIT:30> ) ) <EOL> self . per_page = <NUM_LIT:7> <EOL> self . paginator = self . paginator_class ( <EOL> self . items , self . per_page , orphans = <NUM_LIT:2> ) <EOL> def test_object_list ( self ) : <EOL> first_page = self . paginator . first_page <EOL> expected = self . items [ first_page : first_page + self . per_page ] <EOL> object_list = self . paginator . page ( <NUM_LIT:2> ) . object_list <EOL> self . assertSequenceEqual ( expected , object_list ) <EOL> def test_orphans ( self ) : <EOL> object_list = self . paginator . page ( <NUM_LIT:4> ) . object_list <EOL> self . assertSequenceEqual ( self . items [ - <NUM_LIT:9> : ] , object_list ) <EOL> def test_no_orphans ( self ) : <EOL> paginator = self . paginator_class ( range ( <NUM_LIT:11> ) , <NUM_LIT:8> , orphans = <NUM_LIT:2> ) <EOL> object_list = paginator . page ( <NUM_LIT:2> ) . object_list <EOL> self . assertEqual ( <NUM_LIT:3> , len ( object_list ) ) <EOL> def test_empty_page ( self ) : <EOL> with self . assertRaises ( paginators . EmptyPage ) : <EOL> self . paginator . page ( <NUM_LIT:5> ) <EOL> def test_invalid_page ( self ) : <EOL> with self . assertRaises ( paginators . PageNotAnInteger ) : <EOL> self . paginator . page ( '<STR_LIT>' ) <EOL> with self . assertRaises ( paginators . EmptyPage ) : <EOL> self . paginator . page ( <NUM_LIT:0> ) <EOL> class DifferentFirstPagePaginatorTestMixin ( PaginatorTestMixin ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . items = list ( range ( <NUM_LIT> ) ) <EOL> self . per_page = <NUM_LIT:7> <EOL> self . paginator = self . paginator_class ( <EOL> self . items , self . per_page , first_page = <NUM_LIT:3> , orphans = <NUM_LIT:2> ) <EOL> def test_no_orphans ( self ) : <EOL> paginator = self . paginator_class ( range ( <NUM_LIT:11> ) , <NUM_LIT:5> , first_page = <NUM_LIT:3> , orphans = <NUM_LIT:2> ) <EOL> object_list = paginator . page ( <NUM_LIT:3> ) . object_list <EOL> self . assertEqual ( <NUM_LIT:3> , len ( object_list ) ) <EOL> class DefaultPaginatorTest ( PaginatorTestMixin , TestCase ) : <EOL> paginator_class = paginators . DefaultPaginator <EOL> def test_indexes ( self ) : <EOL> page = self . paginator . page ( <NUM_LIT:2> ) <EOL> self . assertEqual ( self . per_page + <NUM_LIT:1> , page . start_index ( ) ) <EOL> self . assertEqual ( self . per_page * <NUM_LIT:2> , page . end_index ( ) ) <EOL> def test_items_count ( self ) : <EOL> self . assertEqual ( len ( self . items ) , self . paginator . count ) <EOL> def test_num_pages ( self ) : <EOL> self . assertEqual ( <NUM_LIT:4> , self . paginator . num_pages ) <EOL> def test_page_range ( self ) : <EOL> self . assertSequenceEqual ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , self . paginator . page_range ) <EOL> def test_no_items ( self ) : <EOL> paginator = self . paginator_class ( [ ] , <NUM_LIT:10> ) <EOL> page = paginator . page ( <NUM_LIT:1> ) <EOL> self . assertEqual ( <NUM_LIT:0> , paginator . count ) <EOL> self . assertEqual ( <NUM_LIT:0> , page . start_index ( ) ) <EOL> def test_single_page_indexes ( self ) : <EOL> paginator = self . paginator_class ( range ( <NUM_LIT:6> ) , <NUM_LIT:5> , orphans = <NUM_LIT:2> ) <EOL> page = paginator . page ( <NUM_LIT:1> ) <EOL> self . assertEqual ( <NUM_LIT:1> , page . start_index ( ) ) <EOL> self . assertEqual ( <NUM_LIT:6> , page . end_index ( ) ) <EOL> class LazyPaginatorTest ( PaginatorTestMixin , TestCase ) : <EOL> paginator_class = paginators . LazyPaginator <EOL> def test_items_count ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . paginator . count <EOL> def test_num_pages ( self ) : <EOL> self . paginator . page ( <NUM_LIT:2> ) <EOL> self . assertEqual ( <NUM_LIT:3> , self . paginator . num_pages ) <EOL> def test_page_range ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . paginator . page_range <EOL> class DifferentFirstPageDefaultPaginatorTest ( <EOL> DifferentFirstPagePaginatorTestMixin , TestCase ) : <EOL> paginator_class = paginators . DefaultPaginator <EOL> class DifferentFirstPageLazyPaginatorTest ( <EOL> DifferentFirstPagePaginatorTestMixin , TestCase ) : <EOL> paginator_class = paginators . LazyPaginator </s>
