def testDeleteLast(self): testlib.putData(self.txn) self.assertEqual(True, self.c.last()) self.assertEqual(BT('d', ''), self.c.item()) self.assertEqual(True, self.c.delete()) self.assertEqual(BT('', ''), self.c.item()) self.assertEqual(False, self.c.delete()) self.assertEqual(BT('', ''), self.c.item())
def setUp(self): self.path, self.env = testlib.temp_env() db = self.env.open_db(B("db1"), dupsort=True) self.txn = self.env.begin(db, write=True) for _ in range(2): putData(self.txn) self.c = self.txn.cursor() self.empty_entry = ("", "")
def testFilled(self): testlib.putData(self.txn) self.assertEqual(testlib.ITEMS, list(self.c)) self.assertEqual(testlib.ITEMS, list(self.c)) self.assertEqual(testlib.ITEMS, list(self.c.iternext())) self.assertEqual(testlib.ITEMS[::-1], list(self.txn.cursor().iterprev())) self.assertEqual(testlib.ITEMS[::-1], list(self.c.iterprev())) self.assertEqual(testlib.ITEMS, list(self.c))
def setUp(self): self.path, self.env = testlib.temp_env() db = self.env.open_db(B('db1'), dupsort=True) self.txn = self.env.begin(db, write=True) for _ in range(2): putData(self.txn) self.c = self.txn.cursor() self.empty_entry = ('', '')
def testSetRange(self): self.assertEqual(False, self.c.set_range(B('x'))) testlib.putData(self.txn) self.assertEqual(False, self.c.set_range(B('x'))) self.assertEqual(True, self.c.set_range(B('a'))) self.assertEqual(B('a'), self.c.key()) self.assertEqual(True, self.c.set_range(B('ba'))) self.assertEqual(B('baa'), self.c.key()) self.c.set_range(B('')) self.assertEqual(B('a'), self.c.key())
def testDeleteFirst(self): testlib.putData(self.txn) self.assertEqual(False, self.c.delete()) self.c.first() self.assertEqual(BT('a', ''), self.c.item()) self.assertEqual(True, self.c.delete()) self.assertEqual(BT('b', ''), self.c.item()) self.assertEqual(True, self.c.delete()) self.assertEqual(BT('baa', ''), self.c.item()) self.assertEqual(True, self.c.delete()) self.assertEqual(BT('d', ''), self.c.item()) self.assertEqual(True, self.c.delete()) self.assertEqual(BT('', ''), self.c.item()) self.assertEqual(False, self.c.delete()) self.assertEqual(BT('', ''), self.c.item())
def testLastFilled(self): testlib.putData(self.txn) self.assertEqual(True, self.c.last()) self.assertEqual(testlib.ITEMS[-1], self.c.item())
def testCount(self): self.assertRaises(Exception, (lambda: self.c.count())) testlib.putData(self.txn) self.c.first()
def setUp(self): self.path, self.env = testlib.temp_env() # creates 10 databases self.txn = self.env.begin(write=True) putData(self.txn) self.c = self.txn.cursor() self.empty_entry = ("", "")
def testFilledSkipEof(self): testlib.putData(self.txn) self.assertEqual(False, self.c.set_range(B('z'))) self.assertEqual(testlib.REV_ITEMS, list(self.c.iterprev()))
def testFilledSkipReverse(self): testlib.putData(self.txn) self.c.set_range(B('b')) self.assertEqual(testlib.REV_ITEMS[-2:], list(self.c.iterprev()))
def testSetKey(self): self.assertRaises(Exception, (lambda: self.c.set_key(B('')))) self.assertEqual(False, self.c.set_key(B('missing'))) testlib.putData(self.txn) self.assertEqual(True, self.c.set_key(B('b'))) self.assertEqual(False, self.c.set_key(B('ba')))
def setUp(self): self.path, self.env = testlib.temp_env() # creates 10 databases self.txn = self.env.begin(write=True) putData(self.txn) self.c = self.txn.cursor() self.empty_entry = (B(''), B(''))
def testFilledSkipForward(self): testlib.putData(self.txn) self.c.set_range(B('b')) self.assertEqual(testlib.ITEMS[1:], list(self.c))