Ejemplo n.º 1
0
 def test_jumpref_start(self):
     self.db['_design/test'] = {'views': {'test': {'map': 'function(doc) {emit(doc.letter+doc.letter, null);}'}}}
     self.db.update([{'letter': letter} for letter in 'abcdefghijklmnopqrstuvwxyz'])
     pager = Pager(self.db.view, 'test/test')
     prev, items, next, stats = t(pager.get(5, Pager.jumpref('a')))
     assert items[0].key == 'aa'
     prev, items, next, stats = t(pager.get(5, Pager.jumpref('aa')))
     assert items[0].key == 'aa'
Ejemplo n.º 2
0
 def test_jumpref_pageback(self):
     self.db['_design/test'] = {'views': {'test': {'map': 'function(doc) {emit(doc.letter, null);}'}}}
     self.db.update([{'letter': 'a'} for i in range(100)])
     self.db.update([{'letter': 'b'} for i in range(100)])
     pager = Pager(self.db.view, 'test/test')
     prev, items, next, stats = t(pager.get(5, Pager.jumpref('b')))
     assert items[0].key == 'b'
Ejemplo n.º 3
0
 def test_jumpref(self):
     self.db['_design/test'] = {'views': {'test': {'map': 'function(doc) {emit(doc.letter+doc.letter, null);}'}}}
     self.db.update([{'letter': letter} for letter in 'abcdefghijklmnopqrstuvwxyz'])
     pager = Pager(self.db.view, 'test/test')
     p = pager.get(5)
     assert p['items'][0].key == 'aa'
     p = pager.get(5, Pager.jumpref('k'))
     assert p['items'][0].key == 'kk'
     p = pager.get(5, p['prev'])
     assert p['items'][0].key == 'ff'
     p = pager.get(5, p['prev'])
     assert p['items'][0].key == 'aa'
     assert p['prev'] is None
Ejemplo n.º 4
0
 def test_jumpref_exact(self):
     # Tests that the jump key is skipped if it is in the view
     self.db['_design/test'] = {'views': {'test': {'map': 'function(doc) {emit(doc.letter, null);}'}}}
     self.db.update([{'letter': letter} for letter in 'abcdefghijklmnopqrstuvwxyz'])
     pager = Pager(self.db.view, 'test/test')
     prev, items, next, stats = t(pager.get(5))
     assert items[0].key == 'a'
     prev, items, next, stats = t(pager.get(5, Pager.jumpref('k')))
     assert items[0].key == 'k'
     prev, items, next, stats = t(pager.get(5, prev))
     assert items[0].key == 'f'
     prev, items, next, stats = t(pager.get(5, prev))
     assert items[0].key == 'a'
     assert prev is None