mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
280: Renamed Options.options to takes_options; updated related unit tests
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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_),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user