summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-09-29 15:56:23 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-10-03 01:24:57 +0300
commit657d4d88124f3a6b48e543abadd37948c426dca9 (patch)
tree3faec25ecc3a02be92cc69afae6be91f1d30e109 /source4
parent83a15155ebb3399117ce0da7d4e0faa1b72199f9 (diff)
downloadsamba-657d4d88124f3a6b48e543abadd37948c426dca9.tar.gz
samba-657d4d88124f3a6b48e543abadd37948c426dca9.tar.bz2
samba-657d4d88124f3a6b48e543abadd37948c426dca9.zip
s4-test-dsdb_schema_info.py: Get rid of global module variables
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/dsdb/tests/python/dsdb_schema_info.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/source4/dsdb/tests/python/dsdb_schema_info.py b/source4/dsdb/tests/python/dsdb_schema_info.py
index 1d259958d6..9c4f7b1c43 100755
--- a/source4/dsdb/tests/python/dsdb_schema_info.py
+++ b/source4/dsdb/tests/python/dsdb_schema_info.py
@@ -48,29 +48,36 @@ from samba.dcerpc.misc import GUID
class SchemaInfoTestCase(samba.tests.TestCase):
+ # static SamDB connection
+ sam_db = None
+
def setUp(self):
super(SchemaInfoTestCase, self).setUp()
+ # connect SamDB if we haven't yet
+ if self.sam_db is None:
+ ldb_url = samba.tests.env_get_var_value("DC_SERVER")
+ SchemaInfoTestCase.sam_db = samba.tests.connect_samdb(ldb_url)
+
# fetch rootDSE
- self.ldb = ldb
- res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
+ res = self.sam_db.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
self.assertEquals(len(res), 1)
self.schema_dn = res[0]["schemaNamingContext"][0]
self.base_dn = res[0]["defaultNamingContext"][0]
self.forest_level = int(res[0]["forestFunctionality"][0])
# get DC invocation_id
- self.invocation_id = GUID(ldb.get_invocation_id())
+ self.invocation_id = GUID(self.sam_db.get_invocation_id())
def tearDown(self):
super(SchemaInfoTestCase, self).tearDown()
def _getSchemaInfo(self):
try:
- schema_info_data = ldb.searchone(attribute="schemaInfo",
- basedn=self.schema_dn,
- expression="(objectClass=*)",
- scope=SCOPE_BASE)
+ schema_info_data = self.sam_db.searchone(attribute="schemaInfo",
+ basedn=self.schema_dn,
+ expression="(objectClass=*)",
+ scope=SCOPE_BASE)
self.assertEqual(len(schema_info_data), 21)
schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
self.assertEqual(schema_info.marker, 0xFF)
@@ -94,7 +101,7 @@ changetype: modify
add: schemaUpdateNow
schemaUpdateNow: 1
"""
- self.ldb.modify_ldif(ldif)
+ self.sam_db.modify_ldif(ldif)
def _make_obj_names(self, prefix):
obj_name = prefix + time.strftime("%s", time.gmtime())
@@ -128,7 +135,7 @@ systemOnly: FALSE
ldif = self._make_attr_ldif(attr_name, attr_dn)
# add the new attribute
- self.ldb.add_ldif(ldif)
+ self.sam_db.add_ldif(ldif)
self._ldap_schemaUpdateNow()
# compare resulting schemaInfo
schi_after = self._getSchemaInfo()
@@ -137,7 +144,7 @@ systemOnly: FALSE
# rename the Attribute
attr_dn_new = attr_dn.replace(attr_name, attr_name + "-NEW")
try:
- self.ldb.rename(attr_dn, attr_dn_new)
+ self.sam_db.rename(attr_dn, attr_dn_new)
except LdbError, (num, _):
self.fail("failed to change lDAPDisplayName for %s: %s" % (attr_name, _))
@@ -174,7 +181,7 @@ systemOnly: FALSE
ldif = self._make_class_ldif(class_name, class_dn)
# add the new Class
- self.ldb.add_ldif(ldif)
+ self.sam_db.add_ldif(ldif)
self._ldap_schemaUpdateNow()
# compare resulting schemaInfo
schi_after = self._getSchemaInfo()
@@ -183,7 +190,7 @@ systemOnly: FALSE
# rename the Class
class_dn_new = class_dn.replace(class_name, class_name + "-NEW")
try:
- self.ldb.rename(class_dn, class_dn_new)
+ self.sam_db.rename(class_dn, class_dn_new)
except LdbError, (num, _):
self.fail("failed to change lDAPDisplayName for %s: %s" % (class_name, _))
@@ -191,8 +198,3 @@ systemOnly: FALSE
schi_after = self._getSchemaInfo()
self._checkSchemaInfo(schi_before, schi_after)
-
-########################################################################################
-
-ldb_url = samba.tests.env_get_var_value("DC_SERVER")
-ldb = samba.tests.connect_samdb(ldb_url)