summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib/test_crud.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-12-09 09:09:53 -0700
committerJason Gerard DeRose <jderose@redhat.com>2009-12-10 08:29:15 -0700
commitb6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7 (patch)
tree7e5329a51af169ce34a7d275a1bbd63c1e31c026 /tests/test_ipalib/test_crud.py
parentd08b8858ddc3bf6265f6ea8acae6661b9fff5112 (diff)
downloadfreeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.tar.gz
freeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.tar.xz
freeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.zip
Take 2: Extensible return values and validation; steps toward a single output_for_cli(); enable more webUI stuff
Diffstat (limited to 'tests/test_ipalib/test_crud.py')
-rw-r--r--tests/test_ipalib/test_crud.py131
1 files changed, 130 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_crud.py b/tests/test_ipalib/test_crud.py
index a7f49f878..47d51c5dc 100644
--- a/tests/test_ipalib/test_crud.py
+++ b/tests/test_ipalib/test_crud.py
@@ -34,7 +34,6 @@ class CrudChecker(ClassChecker):
"""
Return a finalized `ipalib.plugable.API` instance.
"""
- assert self.cls.__bases__ == (frontend.Method,)
(api, home) = get_api()
class user(frontend.Object):
takes_params = (
@@ -52,6 +51,136 @@ class CrudChecker(ClassChecker):
return api
+class test_Create(CrudChecker):
+ """
+ Test the `ipalib.crud.Create` class.
+ """
+
+ _cls = crud.Create
+
+ def test_get_args(self):
+ """
+ Test the `ipalib.crud.Create.get_args` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.args) == ['uid']
+ assert api.Method.user_verb.args.uid.required is True
+
+ def test_get_options(self):
+ """
+ Test the `ipalib.crud.Create.get_options` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.options) == \
+ ['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_Update(CrudChecker):
+ """
+ Test the `ipalib.crud.Update` class.
+ """
+
+ _cls = crud.Update
+
+ def test_get_args(self):
+ """
+ Test the `ipalib.crud.Update.get_args` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.args) == ['uid']
+ assert api.Method.user_verb.args.uid.required is True
+
+ def test_get_options(self):
+ """
+ Test the `ipalib.crud.Update.get_options` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.options) == \
+ ['givenname', 'sn', 'initials']
+ for param in api.Method.user_verb.options():
+ assert param.required is False
+
+
+class test_Retrieve(CrudChecker):
+ """
+ Test the `ipalib.crud.Retrieve` class.
+ """
+
+ _cls = crud.Retrieve
+
+ def test_get_args(self):
+ """
+ Test the `ipalib.crud.Retrieve.get_args` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.args) == ['uid']
+ assert api.Method.user_verb.args.uid.required is True
+
+ def test_get_options(self):
+ """
+ Test the `ipalib.crud.Retrieve.get_options` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.options) == []
+ assert len(api.Method.user_verb.options) == 0
+
+
+class test_Delete(CrudChecker):
+ """
+ Test the `ipalib.crud.Delete` class.
+ """
+
+ _cls = crud.Delete
+
+ def test_get_args(self):
+ """
+ Test the `ipalib.crud.Delete.get_args` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.args) == ['uid']
+ assert api.Method.user_verb.args.uid.required is True
+
+ def test_get_options(self):
+ """
+ Test the `ipalib.crud.Delete.get_options` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.options) == []
+ assert len(api.Method.user_verb.options) == 0
+
+
+class test_Search(CrudChecker):
+ """
+ Test the `ipalib.crud.Search` class.
+ """
+
+ _cls = crud.Search
+
+ def test_get_args(self):
+ """
+ Test the `ipalib.crud.Search.get_args` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.args) == ['criteria']
+ assert api.Method.user_verb.args.criteria.required is False
+
+ def test_get_options(self):
+ """
+ Test the `ipalib.crud.Search.get_options` method.
+ """
+ api = self.get_api()
+ assert list(api.Method.user_verb.options) == \
+ ['givenname', 'sn', 'uid', 'initials']
+ for param in api.Method.user_verb.options():
+ assert param.required is False
+
+
class test_CrudBackend(ClassChecker):
"""
Test the `ipalib.crud.CrudBackend` class.