diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 01:54:48 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 01:54:48 +0000 |
commit | 0d3be2f421c3cd4044c4d7616d9426ac58a71ce8 (patch) | |
tree | 6f00d8e26dcc277d9b73a2931cfc1fd1afea265e /ipalib/tests/test_public.py | |
parent | 51b639595858c8395f3beb01659ffe0ea69aaf8b (diff) | |
download | freeipa.git-0d3be2f421c3cd4044c4d7616d9426ac58a71ce8.tar.gz freeipa.git-0d3be2f421c3cd4044c4d7616d9426ac58a71ce8.tar.xz freeipa.git-0d3be2f421c3cd4044c4d7616d9426ac58a71ce8.zip |
278: Completed unit tests for Command.args instance attribute
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r-- | ipalib/tests/test_public.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 3841d384..93331f94 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -374,6 +374,7 @@ class test_Command(ClassChecker): def test_class(self): assert self.cls.__bases__ == (plugable.Plugin,) assert self.cls.options == tuple() + assert self.cls.takes_args == tuple() def test_get_args(self): """ @@ -386,13 +387,34 @@ class test_Command(ClassChecker): o = example() assert o.get_args() is args + def __get_instance(self, args=tuple(), options=tuple()): + class example(self.cls): + takes_args = args + takes_options = options + return example() + def test_args(self): """ Tests the ``Command.args`` instance attribute. """ + assert 'args' in self.cls.__public__ # Public ns = self.cls().args assert type(ns) is plugable.NameSpace assert len(ns) == 0 + args = ('destination', 'source?') + ns = self.__get_instance(args=args).args + assert type(ns) is plugable.NameSpace + assert len(ns) == len(args) + assert list(ns) == ['destination', 'source'] + assert type(ns.destination) is public.Option + assert ns.destination.required is True + assert ns.destination.multivalue is False + assert ns.source.required is False + assert ns.source.multivalue is False + + # Test type error: + e = raises(TypeError, self.__get_instance, args=(u'whatever',)) + #assert str(e) == 'arg: need %r or %r; got %r' % (str, public.Option, def test_get_options(self): """ |