tests:samba_tool: pass stdout and stderr to assertCmdSuccess()
[nivanova/samba-autobuild/.git] / python / samba / tests / samba_tool / base.py
index 60ccaa543d7e1132c12253898f26c1dedaa3d9ff..8f00534bf664df9b6bacd98fd42b3e4a540120bb 100644 (file)
@@ -29,7 +29,7 @@ from cStringIO import StringIO
 from samba.netcmd.main import cmd_sambatool
 import samba.tests
 
-class SambaToolCmdTest(samba.tests.TestCaseInTempDir):
+class SambaToolCmdTest(samba.tests.BlackboxTestCase):
 
     def getSamDB(self, *argv):
         """a convenience function to get a samdb instance so that we can query it"""
@@ -67,22 +67,23 @@ class SambaToolCmdTest(samba.tests.TestCaseInTempDir):
         cmd = cmd_sambatool.subcommands[name]
         cmd.outf = StringIO()
         cmd.errf = StringIO()
-        result = cmd._run(name, *args)
+        result = cmd._run("samba-tool %s" % name, *args)
         return (result, cmd.outf.getvalue(), cmd.errf.getvalue())
 
     def runsubcmd(self, name, sub, *args):
         """run a command with sub commands"""
-        # The reason we need this function seperate from runcmd is
+        # The reason we need this function separate from runcmd is
         # that the .outf StringIO assignment is overriden if we use
         # runcmd, so we can't capture stdout and stderr
         cmd = cmd_sambatool.subcommands[name].subcommands[sub]
         cmd.outf = StringIO()
         cmd.errf = StringIO()
-        result = cmd._run(name, *args)
+        result = cmd._run("samba-tool %s %s" % (name, sub), *args)
         return (result, cmd.outf.getvalue(), cmd.errf.getvalue())
 
-    def assertCmdSuccess(self, val, msg=""):
-        self.assertIsNone(val, msg)
+    def assertCmdSuccess(self, exit, out, err, msg=""):
+        self.assertIsNone(exit, msg="exit[%s] stdout[%s] stderr[%s]: %s" % (
+                          exit, out, err, msg))
 
     def assertCmdFail(self, val, msg=""):
         self.assertIsNotNone(val, msg)