예제 #1
0
 def test_remove_hook(self):
     current_page=8
     Paginator(current_page, self.q, self.ROWS)()
     id = Paginator.get_query_id(self.q, self.ROWS)
     self.assertEquals(len(memcache.get(self.q.kind)[id]['cursors'][14]['objects']),2)
     # delete object
     memcache.get(self.q.kind)[id]['cursors'][14]['objects'][0].key.delete()
     # now memcache should be clear
     self.assertIsNone(memcache.get(self.q.kind))
예제 #2
0
    def test_far_page(self):
        #use previous StoreCursor to find the closest cursor
        current_page=8
        Paginator(current_page, self.q, self.ROWS)()
        current_page=10
        result = Paginator(current_page, self.q, self.ROWS)()
        self.assertEquals(len(result['objects']), 2)
        self.assertEquals(result['objects'][0].subject, '18')
        self.assertEquals(result['totalrecords'], self.TOTAL_MESSAGES)
        self.assertEquals(result['totalpages'], 1050)

        id = Paginator.get_query_id(self.q, self.ROWS)
        self.assertEquals(len(memcache.get(self.q.kind)[id]['cursors'][18]['objects']),2)

        #test same page again to get results from cache
        result = Paginator(current_page, self.q, self.ROWS)()
        id = Paginator.get_query_id(self.q, self.ROWS)
        self.assertEquals(len(memcache.get(self.q.kind)[id]['cursors'][18]['objects']),2)