mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
313: Added Object.params instance attribute
This commit is contained in:
parent
cbcadb89e4
commit
49c1c29df1
@ -394,9 +394,20 @@ class Object(plugable.Plugin):
|
||||
__public__ = frozenset((
|
||||
'Method',
|
||||
'Property',
|
||||
'params'
|
||||
))
|
||||
__Method = None
|
||||
__Property = None
|
||||
takes_params = tuple()
|
||||
|
||||
def __init__(self):
|
||||
self.params = plugable.NameSpace(
|
||||
(create_param(p) for p in self.takes_params), sort=False
|
||||
)
|
||||
|
||||
def __create_params(self):
|
||||
for param in self.takes_params:
|
||||
yield create_param(param)
|
||||
|
||||
def __get_Method(self):
|
||||
return self.__Method
|
||||
@ -411,7 +422,6 @@ class Object(plugable.Plugin):
|
||||
self.__Method = self.__create_namespace('Method')
|
||||
self.__Property = self.__create_namespace('Property')
|
||||
|
||||
|
||||
def __create_namespace(self, name):
|
||||
return plugable.NameSpace(self.__filter_members(name))
|
||||
|
||||
|
@ -702,6 +702,24 @@ class test_Object(ClassChecker):
|
||||
assert attr.attr_name == attr_name
|
||||
assert attr.name == attr_name
|
||||
|
||||
def test_params(self):
|
||||
"""
|
||||
Test the ``public.Object.params`` instance attribute.
|
||||
"""
|
||||
ns = self.cls().params
|
||||
assert type(ns) is plugable.NameSpace
|
||||
assert len(ns) == 0
|
||||
class example(self.cls):
|
||||
takes_params = ('banana', 'apple')
|
||||
ns = example().params
|
||||
assert type(ns) is plugable.NameSpace
|
||||
assert len(ns) == 2, repr(ns)
|
||||
assert list(ns) == ['banana', 'apple']
|
||||
for p in ns():
|
||||
assert type(p) is public.Param
|
||||
assert p.required is True
|
||||
assert p.multivalue is False
|
||||
|
||||
|
||||
class test_Attribute(ClassChecker):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user