mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 00:31:56 -06:00
crud.Add.get_args() and get_options() now yield static values in takes_args, takes_options after the automagic ones
This commit is contained in:
parent
887016e69d
commit
87390665f6
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user