summaryrefslogtreecommitdiffstats
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-10-13 23:47:45 +0200
committerJelmer Vernooij <jelmer@samba.org>2011-10-14 00:22:57 +0200
commit37a4bcd28b997eca2c3e5ba60b516b6662bbe6a4 (patch)
treed059cd81fc2cd3385494a550e150c0270ac08b29 /source4/scripting
parent9e1ef61b34b7a4ec63d5bf58e50e64af16a24c43 (diff)
downloadsamba-37a4bcd28b997eca2c3e5ba60b516b6662bbe6a4.tar.gz
samba-37a4bcd28b997eca2c3e5ba60b516b6662bbe6a4.tar.xz
samba-37a4bcd28b997eca2c3e5ba60b516b6662bbe6a4.zip
samba-tool: Add test to make sure all commands have a synopsis set.
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py2
-rw-r--r--source4/scripting/python/samba/netcmd/ntacl.py1
-rw-r--r--source4/scripting/python/samba/tests/netcmd.py26
3 files changed, 26 insertions, 3 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 831ac6ba57b..bf0845726cc 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -168,6 +168,8 @@ class Command(object):
class SuperCommand(Command):
"""A samba-tool command with subcommands."""
+ synopsis = "%prog <subcommand>"
+
subcommands = {}
def _run(self, myname, subcommand=None, *args):
diff --git a/source4/scripting/python/samba/netcmd/ntacl.py b/source4/scripting/python/samba/netcmd/ntacl.py
index 2e5b0c69aa1..9f946139adc 100644
--- a/source4/scripting/python/samba/netcmd/ntacl.py
+++ b/source4/scripting/python/samba/netcmd/ntacl.py
@@ -41,6 +41,7 @@ from samba.netcmd import (
class cmd_ntacl_set(Command):
"""Set ACLs on a file"""
+
synopsis = "%prog <acl> <file> [options]"
takes_options = [
diff --git a/source4/scripting/python/samba/tests/netcmd.py b/source4/scripting/python/samba/tests/netcmd.py
index ac5164b4792..3f6448ac28d 100644
--- a/source4/scripting/python/samba/tests/netcmd.py
+++ b/source4/scripting/python/samba/tests/netcmd.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009-2011
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
from cStringIO import StringIO
from samba.netcmd import Command
from samba.netcmd.testparm import cmd_testparm
+from samba.netcmd.main import cmd_sambatool
import samba.tests
class NetCmdTestCase(samba.tests.TestCase):
@@ -38,6 +39,16 @@ class NetCmdTestCase(samba.tests.TestCase):
self.assertEquals(retcode, retval)
return cmd.outf.getvalue(), cmd.errf.getvalue()
+ def iter_all_subcommands(self):
+ todo = []
+ todo.extend(cmd_sambatool.subcommands.items())
+ while todo:
+ (path, cmd) = todo.pop()
+ yield path, cmd
+ subcmds = getattr(cmd, "subcommands", {})
+ todo.extend([(path + " " + k, v) for (k, v) in
+ subcmds.iteritems()])
+
class TestParmTests(NetCmdTestCase):
@@ -50,14 +61,23 @@ class TestParmTests(NetCmdTestCase):
"required for the host access check\n", err)
-class CommandTests(samba.tests.TestCase):
+class CommandTests(NetCmdTestCase):
def test_description(self):
class cmd_foo(Command):
"""Mydescription"""
- self.assertEquals("Mydescription", cmd_foo().description)
+ self.assertEquals("Mydescription", cmd_foo().short_description)
def test_name(self):
class cmd_foo(Command):
pass
self.assertEquals("foo", cmd_foo().name)
+
+ def test_synopsis_everywhere(self):
+ missing = []
+ for path, cmd in self.iter_all_subcommands():
+ if cmd.synopsis is None:
+ missing.append(path)
+ if missing:
+ self.fail("The following commands do not have a synopsis set: %r" %
+ missing)