diff options
Diffstat (limited to 'lib/tdb/python/tests/simple.py')
-rw-r--r-- | lib/tdb/python/tests/simple.py | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py index 6b1e840f32..18180e16bd 100644 --- a/lib/tdb/python/tests/simple.py +++ b/lib/tdb/python/tests/simple.py @@ -18,6 +18,7 @@ class OpenTdbTests(TestCase): tdb.DEFAULT, os.O_RDWR) class CloseTdbTests(TestCase): + def test_double_close(self): self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR) @@ -28,6 +29,15 @@ class CloseTdbTests(TestCase): self.tdb.close() +class InternalTdbTests(TestCase): + + def test_repr(self): + self.tdb = tdb.Tdb() + + # repr used to crash on internal db + self.assertEquals(repr(self.tdb), "Tdb(<internal>)") + + class SimpleTdbTests(TestCase): def setUp(self): @@ -86,6 +96,9 @@ class SimpleTdbTests(TestCase): def test_map_size(self): self.tdb.map_size + def test_freelist_size(self): + self.tdb.freelist_size + def test_name(self): self.tdb.filename @@ -108,11 +121,13 @@ class SimpleTdbTests(TestCase): self.tdb.transaction_commit() self.assertEquals("1", self.tdb["bloe"]) - def test_iterator(self): + def test_transaction_prepare_commit(self): self.tdb["bloe"] = "2" - self.tdb["bla"] = "hoi" - i = iter(self.tdb) - self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()])) + self.tdb.transaction_start() + self.tdb["bloe"] = "1" + self.tdb.transaction_prepare_commit() + self.tdb.transaction_commit() + self.assertEquals("1", self.tdb["bloe"]) def test_iterkeys(self): self.tdb["bloe"] = "2" @@ -127,11 +142,22 @@ class SimpleTdbTests(TestCase): self.tdb.clear() self.assertEquals(0, len(list(self.tdb))) + def test_seqnum(self): + self.tdb.enable_seqnum() + seq1 = self.tdb.seqnum + self.tdb.increment_seqnum_nonblock() + seq2 = self.tdb.seqnum + self.assertEquals(seq2-seq1, 1) + def test_len(self): self.assertEquals(0, len(list(self.tdb))) self.tdb["entry"] = "value" self.assertEquals(1, len(list(self.tdb))) + def test_add_flags(self): + self.tdb.add_flags(tdb.NOMMAP) + self.tdb.remove_flags(tdb.NOMMAP) + if __name__ == '__main__': import unittest |