diff options
-rw-r--r-- | ipalib/crud.py | 4 | ||||
-rw-r--r-- | tests/test_ipalib/test_crud.py | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py index 9f9d727fd..1bdd03f83 100644 --- a/ipalib/crud.py +++ b/ipalib/crud.py @@ -27,10 +27,14 @@ import frontend, errors class Add(frontend.Method): def get_args(self): yield self.obj.primary_key + for arg in self.takes_args: + yield arg def get_options(self): for param in self.obj.params_minus_pk(): yield param + for option in self.takes_options: + yield option class Get(frontend.Method): diff --git a/tests/test_ipalib/test_crud.py b/tests/test_ipalib/test_crud.py index 1e538cc13..37da503b5 100644 --- a/tests/test_ipalib/test_crud.py +++ b/tests/test_ipalib/test_crud.py @@ -30,7 +30,7 @@ class CrudChecker(ClassChecker): Class for testing base classes in `ipalib.crud`. """ - def get_api(self): + def get_api(self, args=tuple(), options={}): """ Return a finalized `ipalib.plugable.API` instance. """ @@ -49,7 +49,8 @@ class CrudChecker(ClassChecker): 'initials', ) class user_verb(self.cls): - pass + takes_args = args + takes_options = options api.register(user) api.register(user_verb) api.finalize() @@ -70,6 +71,10 @@ class test_Add(CrudChecker): api = self.get_api() assert list(api.Method.user_verb.args) == ['uid'] assert api.Method.user_verb.args.uid.required is True + api = self.get_api(args=('extra?',)) + assert list(api.Method.user_verb.args) == ['uid', 'extra'] + assert api.Method.user_verb.args.uid.required is True + assert api.Method.user_verb.args.extra.required is False def test_get_options(self): """ @@ -80,6 +85,10 @@ class test_Add(CrudChecker): ['givenname', 'sn', 'initials'] for param in api.Method.user_verb.options(): assert param.required is True + api = self.get_api(options=('extra?',)) + assert list(api.Method.user_verb.options) == \ + ['givenname', 'sn', 'initials', 'extra'] + assert api.Method.user_verb.options.extra.required is False class test_Get(CrudChecker): |