summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tests/python/api.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-21 14:51:13 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-21 14:51:13 +0200
commit5209a846a9157e649fcdcb561f7eaf19c8c0e465 (patch)
treeb0a7e52b5646c8eec182dbc391e7934b6804488c /source4/lib/ldb/tests/python/api.py
parent625359b2e266105022309df8985720108ecd6f67 (diff)
parent2ee8d29d22bcb1c350ab59d71b0aee548489bc9c (diff)
downloadsamba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.tar.gz
samba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.tar.bz2
samba-5209a846a9157e649fcdcb561f7eaf19c8c0e465.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv
Conflicts: source4/lib/registry/ldb.c source4/rpc_server/winreg/rpc_winreg.c
Diffstat (limited to 'source4/lib/ldb/tests/python/api.py')
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py38
1 files changed, 33 insertions, 5 deletions
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 99ad1a9e66..4b3501839f 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -2,7 +2,7 @@
# Simple tests for the ldb python bindings.
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-import sys
+import os, sys
import unittest
# Required for the standalone LDB build
@@ -48,6 +48,14 @@ class SimpleLdb(unittest.TestCase):
x = ldb.Ldb()
x.set_modules_dir("/tmp")
+ def test_modules_none(self):
+ x = ldb.Ldb()
+ self.assertEquals([], x.modules())
+
+ def test_modules_tdb(self):
+ x = ldb.Ldb("bar.ldb")
+ self.assertEquals("[<ldb module 'tdb'>]", repr(x.modules()))
+
def test_search(self):
l = ldb.Ldb("foo.ldb")
self.assertEquals(len(l.search()), 1)
@@ -451,12 +459,32 @@ class MessageElementTests(unittest.TestCase):
x = ldb.MessageElement(["foo"])
self.assertEquals("foo", x)
-class ExampleModule:
- name = "example"
-
class ModuleTests(unittest.TestCase):
def test_register_module(self):
- ldb.register_module(ExampleModule())
+ class ExampleModule:
+ name = "example"
+ ldb.register_module(ExampleModule)
+
+ def test_use_module(self):
+ ops = []
+ class ExampleModule:
+ name = "bla"
+
+ def __init__(self, ldb, next):
+ ops.append("init")
+ self.next = next
+
+ def search(self, *args, **kwargs):
+ return self.next.search(*args, **kwargs)
+
+ ldb.register_module(ExampleModule)
+ if os.path.exists("usemodule.ldb"):
+ os.unlink("usemodule.ldb")
+ l = ldb.Ldb("usemodule.ldb")
+ l.add({"dn": "@MODULES", "@LIST": "bla"})
+ self.assertEquals([], ops)
+ l = ldb.Ldb("usemodule.ldb")
+ self.assertEquals(["init"], ops)
if __name__ == '__main__':
import unittest