diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 14:46:20 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 14:46:20 +0000 |
commit | cbfacf7c2ee7387dc95494c6231fd9b256bb68cd (patch) | |
tree | 40e898e47088bed4a82dd95abdf2ccc24e32a4ab /ipalib | |
parent | 8062075f847199157910114588ea3c27874bdf35 (diff) | |
download | freeipa-cbfacf7c2ee7387dc95494c6231fd9b256bb68cd.tar.gz freeipa-cbfacf7c2ee7387dc95494c6231fd9b256bb68cd.tar.xz freeipa-cbfacf7c2ee7387dc95494c6231fd9b256bb68cd.zip |
280: Renamed Options.options to takes_options; updated related unit tests
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/public.py | 6 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 46 |
2 files changed, 26 insertions, 26 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index 437531d6e..7f1929f42 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -229,7 +229,7 @@ class Command(plugable.Plugin): 'args', )) __Option = None - options = tuple() + takes_options = tuple() takes_args = tuple() def __init__(self): @@ -239,7 +239,7 @@ class Command(plugable.Plugin): return self.takes_args def get_options(self): - return self.options + return self.takes_options def __check_args(self): optional = False @@ -425,7 +425,7 @@ class Method(Attribute, Command): Command.__init__(self) def get_options(self): - for option in self.options: + for option in self.takes_options: yield option if self.obj is not None and self.obj.Property is not None: for proxy in self.obj.Property(): diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 93331f941..2c9fbce8d 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -356,7 +356,7 @@ class test_Command(ClassChecker): type_ = ipa_types.Unicode() class example(self.cls): - options = ( + takes_options = ( public.Option('option0', type_, normalize=normalize, default_from=default_from, @@ -373,25 +373,35 @@ class test_Command(ClassChecker): def test_class(self): assert self.cls.__bases__ == (plugable.Plugin,) - assert self.cls.options == tuple() + 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. + """ + class example(self.cls): + takes_args = args + takes_options = options + return example() + def test_get_args(self): """ Tests the `public.Command.get_args` method. """ assert list(self.cls().get_args()) == [] args = ('login', 'stuff') - class example(self.cls): - takes_args = args - o = example() + o = self.__get_instance(args=args) 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_get_options(self): + """ + Tests the `public.Command.get_options` method. + """ + assert list(self.cls().get_options()) == [] + options = ('verbose', 'debug') + o = self.__get_instance(options=options) + assert o.get_options() is options def test_args(self): """ @@ -414,18 +424,8 @@ class test_Command(ClassChecker): # 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): - """ - Tests the `public.Command.get_options` method. - """ - assert list(self.cls().get_options()) == [] - sub = self.subcls() - for (i, option) in enumerate(sub.get_options()): - assert isinstance(option, public.Option) - assert read_only(option, 'name') == 'option%d' % i - assert i == 1 + assert str(e) == \ + 'arg: need %r or %r; got %r' % (str, public.Option, u'whatever') def test_Option(self): """ @@ -691,7 +691,7 @@ class test_Method(ClassChecker): Property = property(__get_prop) type_ = ipa_types.Unicode() class noun_verb(self.cls): - options= ( + takes_options= ( public.Option('option0', type_), public.Option('option1', type_), ) |