summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-24 23:29:15 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-24 23:29:15 +0000
commitbe2e323bbf3f036777acd6e5e16e03f9e66b2ee8 (patch)
tree062cce34ef29b0fad96896a2afb39a4ae0b87193
parentc3b09b2116dcbab36098f11c6b3684a6d0e47c08 (diff)
downloadfreeipa-be2e323bbf3f036777acd6e5e16e03f9e66b2ee8.tar.gz
freeipa-be2e323bbf3f036777acd6e5e16e03f9e66b2ee8.tar.xz
freeipa-be2e323bbf3f036777acd6e5e16e03f9e66b2ee8.zip
353: The Object.parms instance attribute is now created in Object.set_api() instead of in Object.__init__()
-rw-r--r--ipalib/frontend.py9
-rw-r--r--ipalib/tests/test_frontend.py22
2 files changed, 17 insertions, 14 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 132e3039..bcd610a5 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -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))
diff --git a/ipalib/tests/test_frontend.py b/ipalib/tests/test_frontend.py
index 0109934d..f6bca9b9 100644
--- a/ipalib/tests/test_frontend.py
+++ b/ipalib/tests/test_frontend.py
@@ -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']