summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-18 23:15:34 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-18 23:15:34 +0000
commite0b900894fcc884fbde26ba78fa61aedec3843e9 (patch)
tree36074e07ffdc9fbbd06e31f75b7834f8d686228a /ipalib/tests/test_public.py
parentef0d7a71abe0d026b1b79b6dc32d17793a8d7806 (diff)
downloadfreeipa.git-e0b900894fcc884fbde26ba78fa61aedec3843e9.tar.gz
freeipa.git-e0b900894fcc884fbde26ba78fa61aedec3843e9.tar.xz
freeipa.git-e0b900894fcc884fbde26ba78fa61aedec3843e9.zip
300: Added Command.max_args instance attribute; added corresponding unit tests
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r--ipalib/tests/test_public.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py
index 29531d69..80151fa0 100644
--- a/ipalib/tests/test_public.py
+++ b/ipalib/tests/test_public.py
@@ -371,11 +371,6 @@ class test_Command(ClassChecker):
)
return example
- def test_class(self):
- assert self.cls.__bases__ == (plugable.Plugin,)
- assert self.cls.takes_options == tuple()
- assert self.cls.takes_args == tuple()
-
def get_instance(self, args=tuple(), options=tuple()):
"""
Helper method used to test args and options.
@@ -385,6 +380,11 @@ class test_Command(ClassChecker):
takes_options = options
return example()
+ def test_class(self):
+ assert self.cls.__bases__ == (plugable.Plugin,)
+ assert self.cls.takes_options == tuple()
+ assert self.cls.takes_args == tuple()
+
def test_get_args(self):
"""
Tests the `public.Command.get_args` method.
@@ -436,6 +436,21 @@ class test_Command(ClassChecker):
e = raises(ValueError, self.get_instance, args=('arg1+', 'arg2'))
assert str(e) == 'arg2: only final argument can be multivalue'
+ def test_max_args(self):
+ """
+ Test the ``Command.max_args`` instance attribute.
+ """
+ o = self.get_instance()
+ assert o.max_args == 0
+ o = self.get_instance(args=('one?',))
+ assert o.max_args == 1
+ o = self.get_instance(args=('one', 'two?'))
+ assert o.max_args == 2
+ o = self.get_instance(args=('one', 'multi+',))
+ assert o.max_args is None
+ o = self.get_instance(args=('one', 'multi*',))
+ assert o.max_args is None
+
def test_options(self):
"""
Tests the ``Command.options`` instance attribute.