diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-11 03:12:21 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-11 03:12:21 +0200 |
commit | 0fd0fc75c46b39a611c7f9a56081105714d73e36 (patch) | |
tree | b93ef5e67e49a3aa49c37e13df3d6222b2df7095 /source4/lib/ldb/tests | |
parent | 69d38a95c29498c0266cb98b911faa3e7240c787 (diff) | |
parent | 47f7ef8f39ba482a7d6578ab82c9e0670381c4f8 (diff) | |
download | samba-0fd0fc75c46b39a611c7f9a56081105714d73e36.tar.gz samba-0fd0fc75c46b39a611c7f9a56081105714d73e36.tar.bz2 samba-0fd0fc75c46b39a611c7f9a56081105714d73e36.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba into selftest
Conflicts:
selftest/selftest.pl
Diffstat (limited to 'source4/lib/ldb/tests')
-rwxr-xr-x | source4/lib/ldb/tests/python/api.py | 38 | ||||
-rwxr-xr-x | source4/lib/ldb/tests/python/ldap.py | 6 |
2 files changed, 38 insertions, 6 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 diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index bc6f80e856..e2cc658521 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -8,6 +8,7 @@ import sys import time sys.path.append("bin/python") +sys.path.append("../lib/subunit/python") import samba.getopt as options @@ -781,7 +782,10 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertTrue("objectGuid" not in res[0]) self.assertTrue("whenCreated" in res[0]) self.assertTrue("nTSecurityDescriptor" in res[0]) - self.assertEquals(res[0]["member"][0].upper(), ("CN=ldaptestuser2,CN=Users," + self.base_dn).upper()) + memberUP = [] + for m in res[0]["member"]: + memberUP.append(m.upper()) + self.assertTrue(("CN=ldaptestuser2,CN=Users," + self.base_dn).upper() in memberUP) ldb.modify_ldif(""" dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """ |