diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 15:31:34 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 15:31:34 +0000 |
commit | 687f60356203a33b7af24842f24570a12d9b2039 (patch) | |
tree | b95efea6d2ce1d512eb0fe30c567ec866606a779 | |
parent | bde377a2da7bb264ee3188a5696bb389af51321d (diff) | |
download | freeipa.git-687f60356203a33b7af24842f24570a12d9b2039.tar.gz freeipa.git-687f60356203a33b7af24842f24570a12d9b2039.tar.xz freeipa.git-687f60356203a33b7af24842f24570a12d9b2039.zip |
284: Removed depreciated Command.Option property; removed corresponding unit tests; updated affected code
-rw-r--r-- | ipalib/cli.py | 2 | ||||
-rw-r--r-- | ipalib/public.py | 25 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 16 |
3 files changed, 8 insertions, 35 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 25a0a5b8..54693ffd 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -228,7 +228,7 @@ class CLI(object): parser = optparse.OptionParser( usage=self.get_usage(cmd), ) - for option in cmd.Option(): + for option in cmd.options(): parser.add_option('--%s' % to_cli(option.name), metavar=option.type.name.upper(), help=option.doc, diff --git a/ipalib/public.py b/ipalib/public.py index f20ae6d3..c44d039d 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -277,21 +277,10 @@ class Command(plugable.Plugin): ) yield option - def __get_Option(self): - """ - Returns the NameSpace containing the Option instances. - """ - if self.__Option is None: - object.__setattr__(self, '_Command__Option', - plugable.NameSpace(self.get_options()), - ) - return self.__Option - Option = property(__get_Option) - def __convert_iter(self, kw): for (key, value) in kw.iteritems(): - if key in self.Option: - yield (key, self.Option[key].convert(value)) + if key in self.options: + yield (key, self.options[key].convert(value)) else: yield (key, value) @@ -300,8 +289,8 @@ class Command(plugable.Plugin): def __normalize_iter(self, kw): for (key, value) in kw.iteritems(): - if key in self.Option: - yield (key, self.Option[key].normalize(value)) + if key in self.options: + yield (key, self.options[key].normalize(value)) else: yield (key, value) @@ -309,7 +298,7 @@ class Command(plugable.Plugin): return dict(self.__normalize_iter(kw)) def __get_default_iter(self, kw): - for option in self.Option(): + for option in self.options(): if option.name not in kw: value = option.get_default(**kw) if value is not None: @@ -321,7 +310,7 @@ class Command(plugable.Plugin): def validate(self, **kw): self.print_call('validate', kw, 1) - for option in self.Option(): + for option in self.options(): value = kw.get(option.name, None) if value is not None: option.validate(value) @@ -355,7 +344,7 @@ class Command(plugable.Plugin): return 0 return 1 return 2 - for option in sorted(self.Option(), key=get_key): + for option in sorted(self.options(), key=get_key): yield option diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index f805a7a9..5dcbd84c 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -456,22 +456,6 @@ class test_Command(ClassChecker): assert ns.files.required is False assert ns.files.multivalue is True - def test_Option(self): - """ - Tests the `public.Command.Option` property. - """ - assert 'Option' in self.cls.__public__ # Public - sub = self.subcls() - O = sub.Option - assert type(O) is plugable.NameSpace - assert len(O) == 2 - for name in ('option0', 'option1'): - assert name in O - option = O[name] - assert getattr(O, name) is option - assert isinstance(option, public.Option) - assert option.name == name - def test_convert(self): """ Tests the `public.Command.convert` method. |