summaryrefslogtreecommitdiffstats
path: root/ipalib/tests
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-24 02:52:19 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-24 02:52:19 +0000
commit19bbc48eb601bb942ed93776c05bf0c326970832 (patch)
tree55594bbec7966f10ad12ff7ec01b837e6c184084 /ipalib/tests
parent4dbbf5656d4db96068ca6c936120827e52ba5ad8 (diff)
downloadfreeipa-19bbc48eb601bb942ed93776c05bf0c326970832.tar.gz
freeipa-19bbc48eb601bb942ed93776c05bf0c326970832.tar.xz
freeipa-19bbc48eb601bb942ed93776c05bf0c326970832.zip
323: Added Command.run() method that dispatches to execute() or forward(); added corresponding unit tests
Diffstat (limited to 'ipalib/tests')
-rw-r--r--ipalib/tests/test_frontend.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/ipalib/tests/test_frontend.py b/ipalib/tests/test_frontend.py
index d4a70f15a..4ddf11b34 100644
--- a/ipalib/tests/test_frontend.py
+++ b/ipalib/tests/test_frontend.py
@@ -620,6 +620,38 @@ class test_Command(ClassChecker):
assert o.kw_to_args(whatever='hello', two='Two', one='One') == \
('One', 'Two')
+ def test_run(self):
+ """
+ Test the `frontend.Command.run` method.
+ """
+ class my_cmd(self.cls):
+ def execute(self, *args, **kw):
+ return ('execute', args, kw)
+
+ def forward(self, *args, **kw):
+ return ('forward', args, kw)
+
+ args = ('Hello,', 'world,')
+ kw = dict(how_are='you', on_this='fine day?')
+
+ # Test in server context:
+ api = plugable.API(self.cls, in_server_context=True)
+ api.finalize()
+ o = my_cmd()
+ o.set_api(api)
+ assert o.run.im_func is self.cls.run.im_func
+ assert ('execute', args, kw) == o.run(*args, **kw)
+ assert o.run.im_func is my_cmd.execute.im_func
+
+ # Test in non-server context
+ api = plugable.API(self.cls, in_server_context=False)
+ api.finalize()
+ o = my_cmd()
+ o.set_api(api)
+ assert o.run.im_func is self.cls.run.im_func
+ assert ('forward', args, kw) == o.run(*args, **kw)
+ assert o.run.im_func is my_cmd.forward.im_func
+
class test_Object(ClassChecker):
"""