mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
353: The Object.parms instance attribute is now created in Object.set_api() instead of in Object.__init__()
This commit is contained in:
+4
-5
@@ -517,13 +517,9 @@ class Object(plugable.Plugin):
|
||||
))
|
||||
methods = None
|
||||
properties = None
|
||||
params = 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)
|
||||
@@ -532,6 +528,9 @@ class Object(plugable.Plugin):
|
||||
super(Object, self).set_api(api)
|
||||
self.methods = self.__create_namespace('Method')
|
||||
self.properties = self.__create_namespace('Property')
|
||||
self.params = plugable.NameSpace(
|
||||
(create_param(p) for p in self.takes_params), sort=False
|
||||
)
|
||||
|
||||
def __create_namespace(self, name):
|
||||
return plugable.NameSpace(self.__filter_members(name))
|
||||
|
||||
@@ -754,7 +754,7 @@ class test_Command(ClassChecker):
|
||||
|
||||
class test_Object(ClassChecker):
|
||||
"""
|
||||
Tests the `frontend.Object` class.
|
||||
Test the `frontend.Object` class.
|
||||
"""
|
||||
_cls = frontend.Object
|
||||
|
||||
@@ -762,19 +762,22 @@ class test_Object(ClassChecker):
|
||||
assert self.cls.__bases__ == (plugable.Plugin,)
|
||||
assert self.cls.methods is None
|
||||
assert self.cls.properties is None
|
||||
assert self.cls.params is None
|
||||
assert self.cls.takes_params == tuple()
|
||||
|
||||
def test_init(self):
|
||||
"""
|
||||
Tests the `frontend.Object.__init__` method.
|
||||
Test the `frontend.Object.__init__` method.
|
||||
"""
|
||||
o = self.cls()
|
||||
assert o.methods is None
|
||||
assert o.properties is None
|
||||
assert o.params is None
|
||||
assert o.properties is None
|
||||
|
||||
def test_set_api(self):
|
||||
"""
|
||||
Tests the `frontend.Object.set_api` method.
|
||||
Test the `frontend.Object.set_api` method.
|
||||
"""
|
||||
# Setup for test:
|
||||
class DummyAttribute(object):
|
||||
@@ -834,16 +837,17 @@ class test_Object(ClassChecker):
|
||||
assert attr.attr_name == attr_name
|
||||
assert attr.name == attr_name
|
||||
|
||||
def test_params(self):
|
||||
"""
|
||||
Test the ``frontend.Object.params`` instance attribute.
|
||||
"""
|
||||
ns = self.cls().params
|
||||
# Test params instance attribute
|
||||
o = self.cls()
|
||||
o.set_api(api)
|
||||
ns = o.params
|
||||
assert type(ns) is plugable.NameSpace
|
||||
assert len(ns) == 0
|
||||
class example(self.cls):
|
||||
takes_params = ('banana', 'apple')
|
||||
ns = example().params
|
||||
o = example()
|
||||
o.set_api(api)
|
||||
ns = o.params
|
||||
assert type(ns) is plugable.NameSpace
|
||||
assert len(ns) == 2, repr(ns)
|
||||
assert list(ns) == ['banana', 'apple']
|
||||
|
||||
Reference in New Issue
Block a user