From 7f0969d79a45c7ae4c62a319889680bf3117b71c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 1 Nov 2014 20:27:30 -0700 Subject: [PATCH] dirsync test: Create and run a single testsuite, should easy migration to regulary Python unit tests. Change-Id: I6fbffd6453f8af966938943f2895bd6d93f8fb59 Signed-off-by: Jelmer Vernooij Reviewed-by: Andrew Bartlett --- source4/dsdb/tests/python/dirsync.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index f36a3c0d2c6..14810d36312 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -77,12 +77,12 @@ class DirsyncBaseTests(samba.tests.TestCase): def setUp(self): super(DirsyncBaseTests, self).setUp() - self.ldb_admin = ldb - self.base_dn = ldb.domain_dn() - self.domain_sid = security.dom_sid(ldb.get_domain_sid()) + self.ldb_admin = SamDB(ldapshost, credentials=creds, session_info=system_session(lp), lp=lp) + self.base_dn = self.ldb_admin.domain_dn() + self.domain_sid = security.dom_sid(self.ldb_admin.get_domain_sid()) self.user_pass = "samba123@AAA" self.configuration_dn = self.ldb_admin.get_config_basedn().get_linearized() - self.sd_utils = sd_utils.SDUtils(ldb) + self.sd_utils = sd_utils.SDUtils(self.ldb_admin) #used for anonymous login print "baseDN: %s" % self.base_dn @@ -142,7 +142,6 @@ class SimpleDirsyncTests(DirsyncBaseTests): #def test_dirsync_errors(self): - def test_dirsync_supported(self): """Test the basic of the dirsync is supported""" self.ldb_dirsync = self.get_ldb_connection(self.dirsync_user, self.user_pass) @@ -222,9 +221,6 @@ class SimpleDirsyncTests(DirsyncBaseTests): print l self.assertTrue(str(l).find("LDAP_UNWILLING_TO_PERFORM") != -1) - - - def test_dirsync_attributes(self): """Check behavior with some attributes """ res = self.ldb_admin.search(self.base_dn, @@ -590,7 +586,9 @@ class SimpleDirsyncTests(DirsyncBaseTests): expression="(&(objectClass=organizationalUnit)(!(isDeleted=*)))", controls=controls) + class ExtendedDirsyncTests(SimpleDirsyncTests): + def test_dirsync_linkedattributes(self): flag_incr_linked = 2147483648 self.ldb_simple = self.get_ldb_connection(self.simple_user, self.user_pass) @@ -698,14 +696,13 @@ class ExtendedDirsyncTests(SimpleDirsyncTests): self.assertEqual(str(res[0].dn), "") -ldb = SamDB(ldapshost, credentials=creds, session_info=system_session(lp), lp=lp) - runner = SubunitTestRunner() -rc = 0 -# -if not runner.run(unittest.makeSuite(SimpleDirsyncTests)).wasSuccessful(): - rc = 1 -if not runner.run(unittest.makeSuite(ExtendedDirsyncTests)).wasSuccessful(): +suite = unittest.TestSuite() +suite.addTests(unittest.makeSuite(SimpleDirsyncTests)) +suite.addTests(unittest.makeSuite(ExtendedDirsyncTests)) +if not runner.run(suite).wasSuccessful(): rc = 1 +else: + rc = 0 sys.exit(rc) -- 2.11.4.GIT