mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
360: Removed Method.get_options() default implementation; cleaned up unit tests for Method
This commit is contained in:
parent
54c97b4948
commit
9f704e001d
@ -617,13 +617,6 @@ class Method(Attribute, Command):
|
||||
Attribute.__init__(self)
|
||||
Command.__init__(self)
|
||||
|
||||
def get_options(self):
|
||||
for option in self.takes_options:
|
||||
yield option
|
||||
if self.obj is not None and self.obj.params is not None:
|
||||
for param in self.obj.params():
|
||||
yield param
|
||||
|
||||
|
||||
class Property(Attribute):
|
||||
__public__ = frozenset((
|
||||
|
@ -952,39 +952,27 @@ class test_Attribute(ClassChecker):
|
||||
|
||||
class test_Method(ClassChecker):
|
||||
"""
|
||||
Tests the `frontend.Method` class.
|
||||
Test the `frontend.Method` class.
|
||||
"""
|
||||
_cls = frontend.Method
|
||||
|
||||
def test_class(self):
|
||||
assert self.cls.__bases__ == (frontend.Attribute, frontend.Command)
|
||||
assert self.cls.implements(frontend.Command)
|
||||
assert self.cls.implements(frontend.Attribute)
|
||||
|
||||
def get_subcls(self):
|
||||
class example_obj(object):
|
||||
params = plugable.NameSpace(
|
||||
frontend.create_param(n) for n in ('prop0', 'prop1')
|
||||
)
|
||||
type_ = ipa_types.Unicode()
|
||||
class noun_verb(self.cls):
|
||||
takes_options= (
|
||||
frontend.Param('option0', type_),
|
||||
frontend.Param('option1', type_),
|
||||
)
|
||||
obj = example_obj()
|
||||
return noun_verb
|
||||
|
||||
def test_get_options(self):
|
||||
def test_init(self):
|
||||
"""
|
||||
Tests the `frontend.Method.get_options` method.
|
||||
Test the `frontend.Method.__init__` method.
|
||||
"""
|
||||
sub = self.subcls()
|
||||
names = ('option0', 'option1', 'prop0', 'prop1')
|
||||
options = tuple(sub.get_options())
|
||||
assert len(options) == 4
|
||||
for (i, option) in enumerate(options):
|
||||
assert option.name == names[i]
|
||||
assert isinstance(option, frontend.Param)
|
||||
class user_add(self.cls):
|
||||
pass
|
||||
o = user_add()
|
||||
assert o.name == 'user_add'
|
||||
assert o.obj_name == 'user'
|
||||
assert o.attr_name == 'add'
|
||||
assert frontend.Command.implemented_by(o)
|
||||
assert frontend.Attribute.implemented_by(o)
|
||||
|
||||
|
||||
class test_Property(ClassChecker):
|
||||
|
Loading…
Reference in New Issue
Block a user