summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/crud.py4
-rw-r--r--ipalib/frontend.py2
-rw-r--r--ipalib/plugable.py4
-rw-r--r--ipalib/tests/test_crud.py32
4 files changed, 37 insertions, 5 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py
index 9f410fdea..bdcf30478 100644
--- a/ipalib/crud.py
+++ b/ipalib/crud.py
@@ -25,7 +25,9 @@ import frontend, errors
class Add(frontend.Method):
- pass
+ def get_options(self):
+ assert 'params' in self.obj, list(self.obj)
+ return self.obj.params()
class Get(frontend.Method):
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 5573e9446..6cf9b5d7b 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -513,7 +513,7 @@ class Object(plugable.Plugin):
__public__ = frozenset((
'methods',
'properties',
- 'params'
+ 'params',
'primary_key',
))
methods = None
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index e1d728d49..cc61cbe92 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -432,7 +432,7 @@ class PluginProxy(SetProxy):
"""
if key in self.__public__:
return getattr(self.__target, key)
- raise KeyError('no public attribute %r' % key)
+ raise KeyError('no public attribute %s.%s' % (self.name, key))
def __getattr__(self, name):
"""
@@ -441,7 +441,7 @@ class PluginProxy(SetProxy):
"""
if name in self.__public__:
return getattr(self.__target, name)
- raise AttributeError('no public attribute %r' % name)
+ raise AttributeError('no public attribute %s.%s' % (self.name, name))
def __call__(self, *args, **kw):
"""
diff --git a/ipalib/tests/test_crud.py b/ipalib/tests/test_crud.py
index d708d8082..41eb88346 100644
--- a/ipalib/tests/test_crud.py
+++ b/ipalib/tests/test_crud.py
@@ -22,7 +22,23 @@ Unit tests for `ipalib.crud` module.
"""
from tstutil import read_only, raises, ClassChecker
-from ipalib import crud, frontend
+from ipalib import crud, frontend, plugable
+
+def get_api():
+ api = plugable.API(
+ frontend.Object,
+ frontend.Method,
+ frontend.Property,
+ )
+ class user(frontend.Object):
+ takes_params = (
+ 'givenname',
+ 'sn',
+ frontend.Param('uid', primary_key=True),
+ 'initials',
+ )
+ api.register(user)
+ return api
class test_Add(ClassChecker):
@@ -35,6 +51,20 @@ class test_Add(ClassChecker):
def test_class(self):
assert self.cls.__bases__ == (frontend.Method,)
+ def test_get_options(self):
+ """
+ Test the `crud.Add.get_options` method.
+ """
+ api = get_api()
+ class user_add(self.cls):
+ pass
+ api.register(user_add)
+ api.finalize()
+ assert list(api.Method.user_add.args) == []
+ assert list(api.Method.user_add.options) == \
+ ['givenname', 'sn', 'uid', 'initials']
+
+
class test_Get(ClassChecker):
"""