summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-25 03:42:38 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-25 03:42:38 +0000
commitddbe3ae934020fc858f6834a923222c465eba22c (patch)
tree7cf7c1383fa08c2570ee03c804783dec3c3e71ab /ipalib
parent152f3089e15eec0ce9f7af07450785114a3fcb6e (diff)
downloadfreeipa-ddbe3ae934020fc858f6834a923222c465eba22c.tar.gz
freeipa-ddbe3ae934020fc858f6834a923222c465eba22c.tar.xz
freeipa-ddbe3ae934020fc858f6834a923222c465eba22c.zip
364: Implemented Mod.get_args, Mod.get_options(); added corresponding unit tests
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/crud.py9
-rw-r--r--ipalib/tests/test_crud.py18
2 files changed, 25 insertions, 2 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py
index d6d42494a..40b6bd780 100644
--- a/ipalib/crud.py
+++ b/ipalib/crud.py
@@ -26,7 +26,6 @@ import frontend, errors
class Add(frontend.Method):
def get_options(self):
- assert 'params' in self.obj, list(self.obj)
return self.obj.params()
@@ -41,7 +40,13 @@ class Del(frontend.Method):
class Mod(frontend.Method):
- pass
+ def get_args(self):
+ yield self.obj.primary_key
+
+ def get_options(self):
+ for param in self.obj.params_minus_pk():
+ yield param.__clone__(required=False)
+
class Find(frontend.Method):
diff --git a/ipalib/tests/test_crud.py b/ipalib/tests/test_crud.py
index 2cbf4b167..3fcef2c7f 100644
--- a/ipalib/tests/test_crud.py
+++ b/ipalib/tests/test_crud.py
@@ -63,6 +63,8 @@ class test_Add(ClassChecker):
assert list(api.Method.user_add.args) == []
assert list(api.Method.user_add.options) == \
['givenname', 'sn', 'uid', 'initials']
+ for param in api.Method.user_add.options():
+ assert param.required is True
class test_Get(ClassChecker):
@@ -121,6 +123,22 @@ class test_Mod(ClassChecker):
def test_class(self):
assert self.cls.__bases__ == (frontend.Method,)
+ def test_options_args(self):
+ """
+ Test `crud.Mod.get_args` and `crud.Mod.get_options` methods.
+ """
+ api = get_api()
+ class user_mod(self.cls):
+ pass
+ api.register(user_mod)
+ api.finalize()
+ assert list(api.Method.user_mod.args) == ['uid']
+ assert api.Method.user_mod.args[0].required is True
+ assert list(api.Method.user_mod.options) == \
+ ['givenname', 'sn', 'initials']
+ for param in api.Method.user_mod.options():
+ assert param.required is False
+
class test_Find(ClassChecker):
"""