diff options
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/tests/netcmd.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/tests/netcmd.py b/source4/scripting/python/samba/tests/netcmd.py index 7b53d53c3c..4f06124482 100644 --- a/source4/scripting/python/samba/tests/netcmd.py +++ b/source4/scripting/python/samba/tests/netcmd.py @@ -19,10 +19,39 @@ """Tests for samba.netcmd.""" +from cStringIO import StringIO from samba.netcmd import Command +from samba.netcmd.testparm import cmd_testparm import samba.tests +class NetCmdTestCase(samba.tests.TestCase): + + def run_netcmd(self, cmd_klass, args, retcode=0): + cmd = cmd_klass() + cmd.outf = StringIO() + cmd.errf = StringIO() + try: + retval = cmd._run(cmd_klass.__name__, *args) + except Exception, e: + cmd.show_command_error(e) + retval = 1 + self.assertEquals(retcode, retval) + return cmd.outf.getvalue(), cmd.errf.getvalue() + + +class TestParmTests(NetCmdTestCase): + + def test_no_client_ip(self): + out, err = self.run_netcmd(cmd_testparm, ["--client-name=foo"], + retcode=-1) + self.assertEquals("", out) + self.assertEquals( + "ERROR: Both a DNS name and an IP address are " + "required for the host access check\n", err) + + class CommandTests(samba.tests.TestCase): + def test_description(self): class cmd_foo(Command): """Mydescription""" |