diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/crud.py | 8 | ||||
-rw-r--r-- | ipalib/tests/test_crud.py | 16 |
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 |