def test_next_at_end_6pp(self): p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) # Go forward and back the whole way, 5 per page prev, rows, next, stats = t(p.get(6, None)) assert_page(1, prev, rows, next, stats, e6pp_5t) prev, rows, next, stats = t(p.get(6, next)) assert_page(1, prev, rows, next, stats, e6pp_5t)
def test_next_at_end_4pp(self): p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) # Check that using prev again doesn't break prev, rows, next, stats = t(p.get(4, None)) prev, rows, next, stats = t(p.get(4, next)) prev, rows, next, stats = t(p.get(4, next)) assert_page(1, prev, rows, next, stats, e4pp_5t)
def test_upone_downone_4pp(self): p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) # got forward and back one page, 4 per page prev, rows, next, stats = t(p.get(4, None)) assert_page(1, prev, rows, next, stats, e4pp_10t) prev, rows, next, stats = t(p.get(4, next)) assert_page(2, prev, rows, next, stats, e4pp_10t) prev, rows, next, stats = t(p.get(4, prev)) assert_page(1, prev, rows, next, stats, e4pp_10t)
def test_roundtrip_5pp(self): p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) # Go forward and back the whole way, 5 per page prev, rows, next, stats = t(p.get(5, None)) assert_page(1,prev, rows, next, stats, e5pp_10t) prev, rows, next, stats = t(p.get(5, next)) assert_page(2,prev, rows, next, stats, e5pp_10t) prev, rows, next, stats = t(p.get(5, prev)) assert_page(1,prev, rows, next, stats, e5pp_10t)
def test_remove_prevref(self): e5pp_10t_before = [ [0,1,2,3,4], [5,6,7,8,9] ] # Because we're using skiplimit, the next page will start on 6 if id-4 is deleted e5pp_10t_after = [ [0,1,2,3,5], [6,7,8,9] ] p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) prev, rows, next, stats = t(p.get(5, None)) assert_page(1, prev, rows, next, stats, e5pp_10t_before) del self.db['id-4'] prev, rows, next, stats = t(p.get(5, next)) assert_page(2, prev, rows, next, stats, e5pp_10t_after)
def test_prev_at_start_4pp(self): p = SkipLimitPager(self.db.view, '%s/all'%model_type,'%s/count'%model_type) # got forward and back one page, 4 per page prev, rows, next, stats = t(p.get(4, None)) assert_page(1, prev, rows, next, stats, e4pp_10t) prev, rows, next, stats = t(p.get(4, next)) assert_page(2, prev, rows, next, stats, e4pp_10t) prev, rows, next, stats = t(p.get(4, prev)) assert_page(1, prev, rows, next, stats, e4pp_10t) # Check that using prev again doesn't break prev, rows, next, stats = t(p.get(4, prev)) assert_page(1, prev, rows, next, stats, e4pp_10t)