示例#1
0
 def test_min_page_num(self):
     sections = pager.get_sections(page_num=-1, page_count=2)
     self.assertNotIn('previous', sections)
     self.assertNotIn('first', sections)
     self.assertFalse(sections['before'])
     self.assertEqual(sections['current'], [1])
     self.assertEqual(sections['after'], [2])
     self.assertEqual(sections['last'], [2])
     self.assertEqual(sections['next'], [2])
     pages = pager.get_page_numbers(sections)
     self.assertEqual(pages, [1, 2])
示例#2
0
 def test_on_page_999_of_1000(self):
     sections = pager.get_sections(page_num=999, page_count=1000)
     self.assertEqual(sections['previous'], [998])
     self.assertEqual(sections['first'], [1])
     self.assertEqual(sections['before'], [996, 997, 998])
     self.assertEqual(sections['current'], [999])
     self.assertEqual(sections['after'], [1000])
     self.assertEqual(sections['last'], [1000])
     self.assertEqual(sections['next'], [1000])
     pages = pager.get_page_numbers(sections)
     self.assertEqual(pages, [1, 996, 997, 998, 999, 1000])
示例#3
0
 def test_on_page_5_of_9(self):
     sections = pager.get_sections(page_num=5, page_count=9)
     self.assertEqual(sections['previous'], [4])
     self.assertEqual(sections['first'], [1])
     self.assertEqual(sections['before'], [3, 4])
     self.assertEqual(sections['current'], [5])
     self.assertEqual(sections['after'], [6, 7])
     self.assertEqual(sections['last'], [9])
     self.assertEqual(sections['next'], [6])
     pages = pager.get_page_numbers(sections)
     self.assertEqual(pages, [1, 3, 4, 5, 6, 7, 9])
示例#4
0
 def test_on_page_3_of_5(self):
     sections = pager.get_sections(page_num=3, page_count=5)
     self.assertEqual(sections['previous'], [2])
     self.assertEqual(sections['first'], [1])
     self.assertEqual(sections['before'], [1, 2])
     self.assertEqual(sections['current'], [3])
     self.assertEqual(sections['after'], [4, 5])
     self.assertEqual(sections['last'], [5])
     self.assertEqual(sections['next'], [4])
     pages = pager.get_page_numbers(sections)
     self.assertEqual(pages, [1, 2, 3, 4, 5])
示例#5
0
 def test_on_page_1_of_1(self):
     sections = pager.get_sections(page_num=1, page_count=1)
     self.assertIsNone(sections)
     pages = pager.get_page_numbers(sections)
     self.assertFalse(pages)
示例#6
0
 def test_invalid_page_count(self):
     sections = pager.get_sections(page_num=2, page_count=-1)
     self.assertIsNone(sections)