summaryrefslogtreecommitdiffstats
path: root/ipatests/test_ipalib
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2014-03-28 09:51:10 +0100
committerPetr Viktorin <pviktori@redhat.com>2014-04-18 14:59:20 +0200
commit8b6dc819d5e1a74935b270593ca0e6d3f5e5d9d7 (patch)
treecfb83a335b08e993bf719d90ecdbe64fcf617faa /ipatests/test_ipalib
parent4314d02fbf9ef1cb9543ecf76a8d22e79d250214 (diff)
downloadfreeipa-8b6dc819d5e1a74935b270593ca0e6d3f5e5d9d7.tar.gz
freeipa-8b6dc819d5e1a74935b270593ca0e6d3f5e5d9d7.tar.xz
freeipa-8b6dc819d5e1a74935b270593ca0e6d3f5e5d9d7.zip
Support API version-specific RPC marshalling.
Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests/test_ipalib')
-rw-r--r--ipatests/test_ipalib/test_rpc.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 0369d04c4..64e5f5e33 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -29,6 +29,7 @@ from ipatests.data import binary_bytes, utf8_bytes, unicode_str
from ipalib.frontend import Command
from ipalib.request import context, Connection
from ipalib import rpc, errors, api, request
+from ipapython.version import API_VERSION
std_compound = (binary_bytes, utf8_bytes, unicode_str)
@@ -43,7 +44,7 @@ def dump_n_load(value):
def round_trip(value):
return rpc.xml_unwrap(
- dump_n_load(rpc.xml_wrap(value))
+ dump_n_load(rpc.xml_wrap(value, API_VERSION))
)
@@ -90,15 +91,15 @@ def test_xml_wrap():
Test the `ipalib.rpc.xml_wrap` function.
"""
f = rpc.xml_wrap
- assert f([]) == tuple()
- assert f({}) == dict()
- b = f('hello')
+ assert f([], API_VERSION) == tuple()
+ assert f({}, API_VERSION) == dict()
+ b = f('hello', API_VERSION)
assert isinstance(b, Binary)
assert b.data == 'hello'
- u = f(u'hello')
+ u = f(u'hello', API_VERSION)
assert type(u) is unicode
assert u == u'hello'
- value = f([dict(one=False, two=u'hello'), None, 'hello'])
+ value = f([dict(one=False, two=u'hello'), None, 'hello'], API_VERSION)
def test_xml_unwrap():
@@ -127,14 +128,14 @@ def test_xml_dumps():
params = (binary_bytes, utf8_bytes, unicode_str, None)
# Test serializing an RPC request:
- data = f(params, 'the_method')
+ data = f(params, API_VERSION, 'the_method')
(p, m) = loads(data)
assert_equal(m, u'the_method')
assert type(p) is tuple
assert rpc.xml_unwrap(p) == params
# Test serializing an RPC response:
- data = f((params,), methodresponse=True)
+ data = f((params,), API_VERSION, methodresponse=True)
(tup, m) = loads(data)
assert m is None
assert len(tup) == 1
@@ -143,7 +144,7 @@ def test_xml_dumps():
# Test serializing an RPC response containing a Fault:
fault = Fault(69, unicode_str)
- data = f(fault, methodresponse=True)
+ data = f(fault, API_VERSION, methodresponse=True)
e = raises(Fault, loads, data)
assert e.faultCode == 69
assert_equal(e.faultString, unicode_str)
@@ -155,7 +156,7 @@ def test_xml_loads():
"""
f = rpc.xml_loads
params = (binary_bytes, utf8_bytes, unicode_str, None)
- wrapped = rpc.xml_wrap(params)
+ wrapped = rpc.xml_wrap(params, API_VERSION)
# Test un-serializing an RPC request:
data = dumps(wrapped, 'the_method', allow_none=True)
@@ -210,19 +211,19 @@ class test_xmlclient(PluginTester):
conn = DummyClass(
(
'user_add',
- rpc.xml_wrap(params),
+ rpc.xml_wrap(params, API_VERSION),
{},
- rpc.xml_wrap(result),
+ rpc.xml_wrap(result, API_VERSION),
),
(
'user_add',
- rpc.xml_wrap(params),
+ rpc.xml_wrap(params, API_VERSION),
{},
Fault(3007, u"'four' is required"), # RequirementError
),
(
'user_add',
- rpc.xml_wrap(params),
+ rpc.xml_wrap(params, API_VERSION),
{},
Fault(700, u'no such error'), # There is no error 700
),