From 7de450363bc56a747a495803d56cc7c4d1323293 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 10 Sep 2008 15:14:26 +0000 Subject: 282: Added Command.__check_options() method; added unit tests for Command.options instance attribute --- ipalib/tests/test_public.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ipalib/tests') diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 7c9a0244..1f2efe4b 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -417,6 +417,7 @@ class test_Command(ClassChecker): assert len(ns) == len(args) assert list(ns) == ['destination', 'source'] assert type(ns.destination) is public.Option + assert type(ns.source) is public.Option assert ns.destination.required is True assert ns.destination.multivalue is False assert ns.source.required is False @@ -435,6 +436,26 @@ 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_options(self): + """ + Tests the ``Command.options`` instance attribute. + """ + assert 'options' in self.cls.__public__ # Public + ns = self.cls().options + assert type(ns) is plugable.NameSpace + assert len(ns) == 0 + options = ('target', 'files*') + ns = self.__get_instance(options=options).options + assert type(ns) is plugable.NameSpace + assert len(ns) == len(options) + assert list(ns) == ['target', 'files'] + assert type(ns.target) is public.Option + assert type(ns.files) is public.Option + assert ns.target.required is True + assert ns.target.multivalue is False + assert ns.files.required is False + assert ns.files.multivalue is True + def test_Option(self): """ Tests the `public.Command.Option` property. -- cgit