Exemple #1
0
 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())
Exemple #2
0
 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())
Exemple #3
0
 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 = ("", "")
Exemple #4
0
 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))
Exemple #5
0
 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 = ('', '')
Exemple #6
0
 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))
Exemple #7
0
 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())
Exemple #8
0
 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())
Exemple #9
0
 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())
Exemple #10
0
 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())
Exemple #11
0
 def testLastFilled(self):
     testlib.putData(self.txn)
     self.assertEqual(True, self.c.last())
     self.assertEqual(testlib.ITEMS[-1], self.c.item())
Exemple #12
0
 def testCount(self):
     self.assertRaises(Exception, (lambda: self.c.count()))
     testlib.putData(self.txn)
     self.c.first()
Exemple #13
0
 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 = ("", "")
Exemple #14
0
 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()))
Exemple #15
0
 def testFilledSkipReverse(self):
     testlib.putData(self.txn)
     self.c.set_range(B('b'))
     self.assertEqual(testlib.REV_ITEMS[-2:], list(self.c.iterprev()))
Exemple #16
0
 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')))
Exemple #17
0
 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()))
Exemple #18
0
 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(''))
Exemple #19
0
 def testFilledSkipForward(self):
     testlib.putData(self.txn)
     self.c.set_range(B('b'))
     self.assertEqual(testlib.ITEMS[1:], list(self.c))
Exemple #20
0
 def testCount(self):
     self.assertRaises(Exception, (lambda: self.c.count()))
     testlib.putData(self.txn)
     self.c.first()
Exemple #21
0
 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')))
Exemple #22
0
 def testFilledSkipForward(self):
     testlib.putData(self.txn)
     self.c.set_range(B('b'))
     self.assertEqual(testlib.ITEMS[1:], list(self.c))
Exemple #23
0
 def testFilledSkipReverse(self):
     testlib.putData(self.txn)
     self.c.set_range(B('b'))
     self.assertEqual(testlib.REV_ITEMS[-2:], list(self.c.iterprev()))
Exemple #24
0
 def testLastFilled(self):
     testlib.putData(self.txn)
     self.assertEqual(True, self.c.last())
     self.assertEqual(testlib.ITEMS[-1], self.c.item())