mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
352: Now removed Object.Property property and added in its place Object.properties instance attribute
This commit is contained in:
parent
3d6ab69b46
commit
c3b09b2116
@ -512,11 +512,11 @@ class Command(plugable.Plugin):
|
||||
class Object(plugable.Plugin):
|
||||
__public__ = frozenset((
|
||||
'methods',
|
||||
'Property',
|
||||
'properties',
|
||||
'params'
|
||||
))
|
||||
methods = None
|
||||
__Property = None
|
||||
properties = None
|
||||
takes_params = tuple()
|
||||
|
||||
def __init__(self):
|
||||
@ -528,15 +528,10 @@ class Object(plugable.Plugin):
|
||||
for param in self.takes_params:
|
||||
yield create_param(param)
|
||||
|
||||
|
||||
def __get_Property(self):
|
||||
return self.__Property
|
||||
Property = property(__get_Property)
|
||||
|
||||
def set_api(self, api):
|
||||
super(Object, self).set_api(api)
|
||||
self.methods = self.__create_namespace('Method')
|
||||
self.__Property = self.__create_namespace('Property')
|
||||
self.properties = self.__create_namespace('Property')
|
||||
|
||||
def __create_namespace(self, name):
|
||||
return plugable.NameSpace(self.__filter_members(name))
|
||||
@ -596,14 +591,14 @@ class Method(Attribute, Command):
|
||||
def get_options(self):
|
||||
for option in self.takes_options:
|
||||
yield option
|
||||
if self.obj is not None and self.obj.Property is not None:
|
||||
if self.obj is not None and self.obj.properties is not None:
|
||||
def get_key(p):
|
||||
if p.param.required:
|
||||
if p.param.default_from is None:
|
||||
return 0
|
||||
return 1
|
||||
return 2
|
||||
for prop in sorted(self.obj.Property(), key=get_key):
|
||||
for prop in sorted(self.obj.properties(), key=get_key):
|
||||
yield prop.param
|
||||
|
||||
|
||||
|
@ -760,7 +760,9 @@ class test_Object(ClassChecker):
|
||||
|
||||
def test_class(self):
|
||||
assert self.cls.__bases__ == (plugable.Plugin,)
|
||||
assert type(self.cls.Property) is property
|
||||
assert self.cls.methods is None
|
||||
assert self.cls.properties is None
|
||||
assert self.cls.takes_params == tuple()
|
||||
|
||||
def test_init(self):
|
||||
"""
|
||||
@ -768,7 +770,7 @@ class test_Object(ClassChecker):
|
||||
"""
|
||||
o = self.cls()
|
||||
assert o.methods is None
|
||||
assert read_only(o, 'Property') is None
|
||||
assert o.properties is None
|
||||
|
||||
def test_set_api(self):
|
||||
"""
|
||||
@ -798,7 +800,7 @@ class test_Object(ClassChecker):
|
||||
cnt = 10
|
||||
formats = dict(
|
||||
methods='method_%d',
|
||||
Property='property_%d',
|
||||
properties='property_%d',
|
||||
)
|
||||
|
||||
class api(object):
|
||||
@ -806,7 +808,7 @@ class test_Object(ClassChecker):
|
||||
get_attributes(cnt, formats['methods'])
|
||||
)
|
||||
Property = plugable.NameSpace(
|
||||
get_attributes(cnt, formats['Property'])
|
||||
get_attributes(cnt, formats['properties'])
|
||||
)
|
||||
assert len(api.Method) == cnt * 3
|
||||
assert len(api.Property) == cnt * 3
|
||||
@ -818,7 +820,7 @@ class test_Object(ClassChecker):
|
||||
o = user()
|
||||
o.set_api(api)
|
||||
assert read_only(o, 'api') is api
|
||||
for name in ['methods', 'Property']:
|
||||
for name in ['methods', 'properties']:
|
||||
namespace = getattr(o, name)
|
||||
assert isinstance(namespace, plugable.NameSpace)
|
||||
assert len(namespace) == cnt
|
||||
@ -919,7 +921,7 @@ class test_Method(ClassChecker):
|
||||
),
|
||||
])
|
||||
return self.__prop
|
||||
Property = property(__get_prop)
|
||||
properties = property(__get_prop)
|
||||
type_ = ipa_types.Unicode()
|
||||
class noun_verb(self.cls):
|
||||
takes_options= (
|
||||
|
Loading…
Reference in New Issue
Block a user