summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-11-25 13:52:40 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-11-25 13:52:40 -0700
commit29d680b211021fe755522f4453853344233bc78e (patch)
treee667b1fc51982955bd562747b82d53fcd139b07b /tests
parent7350ccbffefdf81992b3ccd8aac814f3bb954be8 (diff)
downloadfreeipa-29d680b211021fe755522f4453853344233bc78e.tar.gz
freeipa-29d680b211021fe755522f4453853344233bc78e.tar.xz
freeipa-29d680b211021fe755522f4453853344233bc78e.zip
Continued work on xmlrpc.dispatch() unit tests; fixed bug in Command.args_to_kw()
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ipa_server/test_rpc.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/test_ipa_server/test_rpc.py b/tests/test_ipa_server/test_rpc.py
index 6c46b130a..f73f6cd0d 100644
--- a/tests/test_ipa_server/test_rpc.py
+++ b/tests/test_ipa_server/test_rpc.py
@@ -22,6 +22,7 @@ Test the `ipa_server.rpc` module.
"""
from tests.util import create_test_api, raises, PluginTester
+from tests.data import unicode_str
from ipalib import errors, Command
from ipa_server import rpc
@@ -51,7 +52,25 @@ class test_xmlrpc(PluginTester):
"""
Test the `ipa_server.rpc.xmlrpc.dispatch` method.
"""
- (o, api, home) = self.instance('Backend')
- e = raises(errors.CommandError, o.dispatch, 'example', tuple())
- assert str(e) == "Unknown command 'example'"
- assert e.kw['name'] == 'example'
+ (o, api, home) = self.instance('Backend', in_server=True)
+ e = raises(errors.CommandError, o.dispatch, 'echo', tuple())
+ assert str(e) == "Unknown command 'echo'"
+ assert e.kw['name'] == 'echo'
+
+ class echo(Command):
+ takes_args = ['arg1', 'arg2+']
+ takes_options = ['option1?', 'option2?']
+ def execute(self, *args, **options):
+ assert type(args[1]) is tuple
+ return args + (options,)
+
+ (o, api, home) = self.instance('Backend', echo, in_server=True)
+ def call(params):
+ response = o.dispatch('echo', params)
+ assert type(response) is tuple and len(response) == 1
+ return response[0]
+ arg1 = unicode_str
+ arg2 = (u'Hello', unicode_str, u'world!')
+ options = dict(option1=u'How are you?', option2=unicode_str)
+ assert call((arg1, arg2, options)) == (arg1, arg2, options)
+ assert call((arg1,) + arg2 + (options,)) == (arg1, arg2, options)