summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-25 03:47:22 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-25 03:47:22 +0000
commit55ba8e9d0b86bf25a2cbb7a3a603d796e7a2be2b (patch)
tree62a5ac3ab350d90ae44dbeae046bcf34f0677346
parentddbe3ae934020fc858f6834a923222c465eba22c (diff)
downloadfreeipa-55ba8e9d0b86bf25a2cbb7a3a603d796e7a2be2b.tar.gz
freeipa-55ba8e9d0b86bf25a2cbb7a3a603d796e7a2be2b.tar.xz
freeipa-55ba8e9d0b86bf25a2cbb7a3a603d796e7a2be2b.zip
365: Implemented find.get_args(), find.get_options(); added corresponding unit tests
-rw-r--r--ipalib/crud.py8
-rw-r--r--ipalib/tests/test_crud.py16
2 files changed, 22 insertions, 2 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py
index 40b6bd78..5021d06d 100644
--- a/ipalib/crud.py
+++ b/ipalib/crud.py
@@ -48,6 +48,10 @@ class Mod(frontend.Method):
yield param.__clone__(required=False)
-
class Find(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)
diff --git a/ipalib/tests/test_crud.py b/ipalib/tests/test_crud.py
index 3fcef2c7..8b1e8a86 100644
--- a/ipalib/tests/test_crud.py
+++ b/ipalib/tests/test_crud.py
@@ -149,3 +149,19 @@ class test_Find(ClassChecker):
def test_class(self):
assert self.cls.__bases__ == (frontend.Method,)
+
+ def test_options_args(self):
+ """
+ Test `crud.Find.get_args` and `crud.Find.get_options` methods.
+ """
+ api = get_api()
+ class user_find(self.cls):
+ pass
+ api.register(user_find)
+ api.finalize()
+ assert list(api.Method.user_find.args) == ['uid']
+ assert api.Method.user_find.args[0].required is True
+ assert list(api.Method.user_find.options) == \
+ ['givenname', 'sn', 'initials']
+ for param in api.Method.user_find.options():
+ assert param.required is False