summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-06-19 18:58:18 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-19 22:46:45 +0200
commitc92db7b6dc31756fc461ea9f74e1cd675e3e160d (patch)
tree14a1cb47c782b42ab023e1e462447ee55ddeb179 /source4/lib/ldb
parent105ebb34405eb458c51ebbfb57b3ce31a41c34e2 (diff)
downloadsamba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.tar.gz
samba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.tar.bz2
samba-c92db7b6dc31756fc461ea9f74e1cd675e3e160d.zip
python: Use samba.tests.TestCase, make sure base class tearDown and
setUp methods are called, fix formatting.
Diffstat (limited to 'source4/lib/ldb')
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py5
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py4
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap_schema.py5
-rwxr-xr-xsource4/lib/ldb/tests/python/passwords.py3
-rwxr-xr-xsource4/lib/ldb/tests/python/sec_descriptor.py24
-rwxr-xr-xsource4/lib/ldb/tests/python/urgent_replication.py4
6 files changed, 24 insertions, 21 deletions
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 6303f6b6cb..4b4415afb1 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -2,12 +2,9 @@
# Simple tests for the ldb python bindings.
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-import os, sys
+import os
import unittest
-# Required for the standalone LDB build
-sys.path.append("build/lib.linux-i686-2.4")
-
import ldb
def filename():
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index db1a47ce64..98ff628dfe 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -81,6 +81,7 @@ class BasicTests(unittest.TestCase):
return ndr_unpack( security.dom_sid,res[0]["objectSid"][0])
def setUp(self):
+ super(BasicTests, self).setUp()
self.ldb = ldb
self.gc_ldb = gc_ldb
self.base_dn = self.find_basedn(ldb)
@@ -2569,8 +2570,11 @@ nTSecurityDescriptor:: """ + desc_base64
finally:
self.delete_force(self.ldb, user_dn)
+
class BaseDnTests(unittest.TestCase):
+
def setUp(self):
+ super(BaseDnTests, self).setUp()
self.ldb = ldb
def test_rootdse_attrs(self):
diff --git a/source4/lib/ldb/tests/python/ldap_schema.py b/source4/lib/ldb/tests/python/ldap_schema.py
index ceebe11187..8e6865a4d2 100755
--- a/source4/lib/ldb/tests/python/ldap_schema.py
+++ b/source4/lib/ldb/tests/python/ldap_schema.py
@@ -45,6 +45,7 @@ creds = credopts.get_credentials(lp)
class SchemaTests(unittest.TestCase):
+
def delete_force(self, ldb, dn):
try:
ldb.delete(dn)
@@ -63,6 +64,7 @@ class SchemaTests(unittest.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(SchemaTests, self).setUp()
self.ldb = ldb
self.schema_dn = self.find_schemadn(ldb)
self.base_dn = self.find_basedn(ldb)
@@ -214,6 +216,7 @@ name: """ + object_name + """
class SchemaTests_msDS_IntId(unittest.TestCase):
def setUp(self):
+ super(SchemaTests_msDS_IntId, self).setUp()
self.ldb = ldb
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
self.assertEquals(len(res), 1)
@@ -481,9 +484,11 @@ systemOnly: FALSE
else:
self.assertTrue("msDS-IntId" not in ldb_msg)
+
class SchemaTests_msDS_isRODC(unittest.TestCase):
def setUp(self):
+ super(SchemaTests_msDS_isRODC, self).setUp()
self.ldb = ldb
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
self.assertEquals(len(res), 1)
diff --git a/source4/lib/ldb/tests/python/passwords.py b/source4/lib/ldb/tests/python/passwords.py
index b3e6fc949e..dd5a1ca126 100755
--- a/source4/lib/ldb/tests/python/passwords.py
+++ b/source4/lib/ldb/tests/python/passwords.py
@@ -12,7 +12,6 @@
import optparse
import sys
-import time
import base64
import os
@@ -75,6 +74,7 @@ class PasswordTests(samba.tests.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(PasswordTests, self).setUp()
self.ldb = ldb
self.base_dn = self.find_basedn(ldb)
@@ -558,6 +558,7 @@ userPassword: thatsAcomplPASS4
"userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] })
def tearDown(self):
+ super(PasswordTests, self).tearDown()
self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn)
self.delete_force(self.ldb, "cn=testuser2,cn=users," + self.base_dn)
# Close the second LDB connection (with the user credentials)
diff --git a/source4/lib/ldb/tests/python/sec_descriptor.py b/source4/lib/ldb/tests/python/sec_descriptor.py
index 43437fa186..91f607714e 100755
--- a/source4/lib/ldb/tests/python/sec_descriptor.py
+++ b/source4/lib/ldb/tests/python/sec_descriptor.py
@@ -19,7 +19,6 @@ from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT
from samba.ndr import ndr_pack, ndr_unpack
from samba.dcerpc import security
-from samba import Ldb
from samba import gensec
from samba.samdb import SamDB
from samba.credentials import Credentials
@@ -28,6 +27,7 @@ from samba.dsdb import DS_DOMAIN_FUNCTION_2008
from samba.dcerpc.security import (
SECINFO_OWNER, SECINFO_GROUP, SECINFO_DACL, SECINFO_SACL)
from subunit.run import SubunitTestRunner
+import samba.tests
import unittest
parser = optparse.OptionParser("sec_descriptor [options] <host>")
@@ -54,7 +54,7 @@ creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL)
# Tests start here
#
-class DescriptorTests(unittest.TestCase):
+class DescriptorTests(samba.tests.TestCase):
def delete_force(self, ldb, dn):
try:
@@ -271,6 +271,7 @@ member: """ + self.get_users_domain_dn(username)
self.ldb_admin.enable_account("(sAMAccountName=" + username + ")")
def setUp(self):
+ super(DescriptorTests, self).setUp()
self.ldb_admin = ldb
self.base_dn = self.find_basedn(self.ldb_admin)
self.configuration_dn = self.find_configurationdn(self.ldb_admin)
@@ -307,7 +308,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "CN=test-container1,CN=DisplaySpecifiers," + self.configuration_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(OwnerGroupDescriptorTests, self).setUp()
self.deleteAll()
### Create users
# User 1
@@ -453,6 +454,7 @@ class OwnerGroupDescriptorTests(DescriptorTests):
self.DS_BEHAVIOR = "ds_behavior_win2008"
def tearDown(self):
+ super(DescriptorTests, self).tearDown()
self.deleteAll()
def check_user_belongs(self, user_dn, groups=[]):
@@ -1364,10 +1366,7 @@ class DaclDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_inherit_ou," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
- self.deleteAll()
-
- def tearDown(self):
+ super(DaclDescriptorTests, self).setUp()
self.deleteAll()
def create_clean_ou(self, object_dn):
@@ -1696,13 +1695,10 @@ class SdFlagsDescriptorTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_sdflags_ou," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(SdFlagsDescriptorTests, self).setUp()
self.test_descr = "O:AUG:AUD:(D;;CC;;;LG)S:(OU;;WP;;;AU)"
self.deleteAll()
- def tearDown(self):
- self.deleteAll()
-
def test_301(self):
""" Modify a descriptor with OWNER_SECURITY_INFORMATION set.
See that only the owner has been changed.
@@ -1849,6 +1845,7 @@ class SdFlagsDescriptorTests(DescriptorTests):
self.assertFalse("S:" in desc_sddl)
self.assertFalse("G:" in desc_sddl)
+
class RightsAttributesTests(DescriptorTests):
def deleteAll(self):
@@ -1857,7 +1854,7 @@ class RightsAttributesTests(DescriptorTests):
self.delete_force(self.ldb_admin, "OU=test_domain_ou1," + self.base_dn)
def setUp(self):
- DescriptorTests.setUp(self)
+ super(RightsAttributesTests, self).setUp()
self.deleteAll()
### Create users
# User 1
@@ -1866,9 +1863,6 @@ class RightsAttributesTests(DescriptorTests):
self.create_enable_user("testuser_attr2")
self.add_user_to_group(self.ldb_admin, "testuser_attr2", "Domain Admins")
- def tearDown(self):
- self.deleteAll()
-
def test_sDRightsEffective(self):
object_dn = "OU=test_domain_ou1," + self.base_dn
self.delete_force(self.ldb_admin, object_dn)
diff --git a/source4/lib/ldb/tests/python/urgent_replication.py b/source4/lib/ldb/tests/python/urgent_replication.py
index 78200efc30..26f7d9b46d 100755
--- a/source4/lib/ldb/tests/python/urgent_replication.py
+++ b/source4/lib/ldb/tests/python/urgent_replication.py
@@ -15,6 +15,7 @@ from samba.auth import system_session
from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
MessageElement, Dn, FLAG_MOD_REPLACE)
from samba.samdb import SamDB
+import samba.tests
from subunit.run import SubunitTestRunner
import unittest
@@ -37,7 +38,7 @@ host = args[0]
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
-class UrgentReplicationTests(unittest.TestCase):
+class UrgentReplicationTests(samba.tests.TestCase):
def delete_force(self, ldb, dn):
try:
@@ -52,6 +53,7 @@ class UrgentReplicationTests(unittest.TestCase):
return res[0]["defaultNamingContext"][0]
def setUp(self):
+ super(UrgentReplicationTests, self).setUp()
self.ldb = ldb
self.base_dn = self.find_basedn(ldb)