summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/python/tests
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2008-01-06 23:17:55 -0600
committerStefan Metzmacher <metze@samba.org>2008-01-06 17:21:02 -0600
commite45c7ffb800448c41ee0fd69e6ebd87446b116e5 (patch)
tree4b848308cace264b1aa28e43b8065108809d4bb3 /source4/lib/tdb/python/tests
parent9d09a06920c2de8c6312f3c0a0280faee65fd432 (diff)
downloadsamba-e45c7ffb800448c41ee0fd69e6ebd87446b116e5.tar.gz
samba-e45c7ffb800448c41ee0fd69e6ebd87446b116e5.tar.bz2
samba-e45c7ffb800448c41ee0fd69e6ebd87446b116e5.zip
r26677: Implement and test iter{keys,values,items} for tdb bindings.
Use tempfile.mkstemp() instead of os.tmpnam() in tests. (This used to be commit 5c3c131d174ba0f162c210d3e6ca30f2ed2a3ec0)
Diffstat (limited to 'source4/lib/tdb/python/tests')
-rw-r--r--source4/lib/tdb/python/tests/simple.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py
index 698a77f942..1cc51aea07 100644
--- a/source4/lib/tdb/python/tests/simple.py
+++ b/source4/lib/tdb/python/tests/simple.py
@@ -8,7 +8,7 @@
import tdb
from unittest import TestCase
-import os
+import os, tempfile
class OpenTdbTests(TestCase):
@@ -19,7 +19,7 @@ class OpenTdbTests(TestCase):
class SimpleTdbTests(TestCase):
def setUp(self):
super(SimpleTdbTests, self).setUp()
- self.tdb = tdb.Tdb(os.tmpnam(), 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR)
+ self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR)
self.assertNotEqual(None, self.tdb)
def tearDown(self):
@@ -82,6 +82,13 @@ class SimpleTdbTests(TestCase):
self.tdb["brainslug"] = "2"
self.assertEquals([("bla", "1"), ("brainslug", "2")], self.tdb.items())
+ def test_iteritems(self):
+ self.tdb["bloe"] = "2"
+ self.tdb["bla"] = "25"
+ i = self.tdb.iteritems()
+ self.assertEquals(set([("bla", "25"), ("bloe", "2")]),
+ set([i.next(), i.next()]))
+
def test_transaction_cancel(self):
self.tdb["bloe"] = "2"
self.tdb.transaction_start()
@@ -107,11 +114,23 @@ class SimpleTdbTests(TestCase):
self.tdb["bla"] = "25"
self.assertEquals(["bla", "bloe"], self.tdb.keys())
+ def test_iterkeys(self):
+ self.tdb["bloe"] = "2"
+ self.tdb["bla"] = "25"
+ i = self.tdb.iterkeys()
+ self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()]))
+
def test_values(self):
self.tdb["bloe"] = "2"
self.tdb["bla"] = "25"
self.assertEquals(["25", "2"], self.tdb.values())
+ def test_itervalues(self):
+ self.tdb["bloe"] = "2"
+ self.tdb["bla"] = "25"
+ i = self.tdb.itervalues()
+ self.assertEquals(set(["25", "2"]), set([i.next(), i.next()]))
+
def test_clear(self):
self.tdb["bloe"] = "2"
self.tdb["bla"] = "25"