365: Implemented find.get_args(), find.get_options(); added corresponding unit tests
This commit is contained in:
1 parent
ddbe3ae934
commit
55ba8e9d0b
2 files changed
+22
-2
No files matched your search
+6
-2
@@ -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)
|
||||
@@ -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
|
||||
Reference in new issue
Block a user