svn commit: samba r25344 - in branches/4.0-python: . source/lib/tdb
source/lib/tdb/python source/lib/tdb/python/tests
jelmer at samba.org
jelmer at samba.org
Wed Sep 26 02:06:26 GMT 2007
Author: jelmer
Date: 2007-09-26 02:06:26 +0000 (Wed, 26 Sep 2007)
New Revision: 25344
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25344
Log:
Add some simple tests that define the interface of the tdb python bindings.
Added:
branches/4.0-python/source/lib/tdb/python/
branches/4.0-python/source/lib/tdb/python/tests/
branches/4.0-python/source/lib/tdb/python/tests/simple.py
Modified:
branches/4.0-python/
Changeset:
Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Added: branches/4.0-python/source/lib/tdb/python/tests/simple.py
===================================================================
--- branches/4.0-python/source/lib/tdb/python/tests/simple.py 2007-09-26 02:06:23 UTC (rev 25343)
+++ branches/4.0-python/source/lib/tdb/python/tests/simple.py 2007-09-26 02:06:26 UTC (rev 25344)
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# Some simple tests for the Python bindings for TDB
+# Note that this tests the interface of the Python bindings
+# It does not test tdb itself.
+#
+# Copyright (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU LGPL
+from tdb import Tdb
+from unittest import TestCase
+
+class SimpleTdbTests(TestCase):
+ def setUp(self):
+ super(SimpleTdbTests, self).setUp()
+ self.tdb = Tdb("sometempfile")
+
+ def test_lockall(self):
+ self.tdb.lockall()
+
+ def test_max_dead(self):
+ self.tdb.max_dead = 20
+
+ def test_unlockall(self):
+ self.tdb.lock_all()
+ self.tdb.unlock_all()
+
+ def test_lockall_read(self):
+ self.tdb.read_lock_all()
+ self.tdb.read_unlock_all()
+
+ def test_reopen(self):
+ self.tdb.reopen()
+
+ def test_set_logging_fn(self):
+ self.tdb.log_fn = lambda tdb, level, txt: ""
+
+ def test_get_logging_fn(self):
+ self.tdb.log_fn
+
+ def test_fetch(self):
+ self.tdb["bar"] = "foo"
+ self.tdb.reopen()
+ self.assertEquals("foo", self.tdb["bar"])
+
+ def test_delete(self):
+ self.tdb["bar"] = "foo"
+ del self.tdb["bar"]
+ self.assertIs(None, self.tdb["bar"])
+
+ def test_contains(self):
+ self.tdb["bla"] = "bloe"
+ self.assertTrue("bla" in self.tdb)
+
+ def test_hash_size(self):
+ self.tdb.hash_size
+
+ def test_map_size(self):
+ self.tdb.map_size
+
+ def test_name(self):
+ self.tdb.name
+
+ def test_iterator(self):
+ self.tdb["bla"] = 1
+ self.tdb["brainslug"] = 2
+ self.assertEquals(["bla", "brainslug"], list(self.tdb))
+
+ def test_items(self):
+ self.tdb["bla"] = 1
+ self.tdb["brainslug"] = 2
+ self.assertEquals([("bla", 1), ("brainslug", 2)], self.tdb.items())
+
+ def test_transaction_cancel(self):
+ self.tdb["bloe"] = 2
+ self.tdb.transaction_start()
+ self.tdb["bloe"] = 1
+ self.tdb.transaction_cancel()
+ self.assertEquals(2, self.tdb["bloe"])
+
+ def test_transaction_commit(self):
+ self.tdb["bloe"] = 2
+ self.tdb.transaction_start()
+ self.tdb["bloe"] = 1
+ self.tdb.transaction_commit()
+ self.assertEquals(1, self.tdb["bloe"])
More information about the samba-cvs
mailing list