Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: appengine/monorail/framework/test/paginate_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Unit tests for pagination classes."""
7
8 import unittest
9
10 from framework import paginate
11 from testing import testing_helpers
12
13
14 class PaginateTest(unittest.TestCase):
15
16 def testVirtualPagination(self):
17 # Paginating 0 results on a page that can hold 100.
18 mr = testing_helpers.MakeMonorailRequest(path='/issues/list')
19 vp = paginate.VirtualPagination(mr, 0, 100)
20 self.assertEquals(vp.num, 100)
21 self.assertEquals(vp.start, 1)
22 self.assertEquals(vp.last, 0)
23 self.assertFalse(vp.visible)
24
25 # Paginationg 12 results on a page that can hold 100.
26 mr = testing_helpers.MakeMonorailRequest(path='/issues/list')
27 vp = paginate.VirtualPagination(mr, 12, 100)
28 self.assertEquals(vp.num, 100)
29 self.assertEquals(vp.start, 1)
30 self.assertEquals(vp.last, 12)
31 self.assertTrue(vp.visible)
32
33 # Paginationg 12 results on a page that can hold 10.
34 mr = testing_helpers.MakeMonorailRequest(path='/issues/list?num=10')
35 vp = paginate.VirtualPagination(mr, 12, 100)
36 self.assertEquals(vp.num, 10)
37 self.assertEquals(vp.start, 1)
38 self.assertEquals(vp.last, 10)
39 self.assertTrue(vp.visible)
40
41 # Paginationg 12 results starting at 5 on page that can hold 10.
42 mr = testing_helpers.MakeMonorailRequest(
43 path='/issues/list?start=5&num=10')
44 vp = paginate.VirtualPagination(mr, 12, 100)
45 self.assertEquals(vp.num, 10)
46 self.assertEquals(vp.start, 6)
47 self.assertEquals(vp.last, 12)
48 self.assertTrue(vp.visible)
49
50 # Paginationg 123 results on a page that can hold 100.
51 mr = testing_helpers.MakeMonorailRequest(path='/issues/list')
52 vp = paginate.VirtualPagination(mr, 123, 100)
53 self.assertEquals(vp.num, 100)
54 self.assertEquals(vp.start, 1)
55 self.assertEquals(vp.last, 100)
56 self.assertTrue(vp.visible)
57
58 # Paginationg 123 results on second page that can hold 100.
59 mr = testing_helpers.MakeMonorailRequest(path='/issues/list?start=100')
60 vp = paginate.VirtualPagination(mr, 123, 100)
61 self.assertEquals(vp.num, 100)
62 self.assertEquals(vp.start, 101)
63 self.assertEquals(vp.last, 123)
64 self.assertTrue(vp.visible)
65
66 # Paginationg a huge number of objects will show at most 5000 per page.
67 mr = testing_helpers.MakeMonorailRequest(path='/issues/list?num=9999')
68 vp = paginate.VirtualPagination(mr, 12345, 100)
69 self.assertEquals(vp.num, 1000)
70 self.assertEquals(vp.start, 1)
71 self.assertEquals(vp.last, 1000)
72 self.assertTrue(vp.visible)
73
74
75 if __name__ == '__main__':
76 unittest.main()
OLDNEW
« no previous file with comments | « appengine/monorail/framework/test/monorailrequest_test.py ('k') | appengine/monorail/framework/test/permissions_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698