From 24b6cb89d443384cb432f01265c45bc18d9cf2fc Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 22 Jan 2009 15:41:54 -0700 Subject: Further migration toward new xmlrcp code; fixed problem with unicode Fault.faultString; fixed problem where ServerProxy method was not called correctly --- tests/test_ipalib/test_frontend.py | 2 -- tests/test_ipalib/test_parameters.py | 2 ++ tests/test_ipalib/test_rpc.py | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'tests/test_ipalib') diff --git a/tests/test_ipalib/test_frontend.py b/tests/test_ipalib/test_frontend.py index 1e90dbb34..72fc889e6 100644 --- a/tests/test_ipalib/test_frontend.py +++ b/tests/test_ipalib/test_frontend.py @@ -378,7 +378,6 @@ class test_Command(ClassChecker): 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, home) = create_test_api(in_server=False) @@ -387,7 +386,6 @@ class test_Command(ClassChecker): 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_LocalOrRemote(ClassChecker): diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py index e9e514eb1..b3ab996df 100644 --- a/tests/test_ipalib/test_parameters.py +++ b/tests/test_ipalib/test_parameters.py @@ -335,6 +335,7 @@ class test_Param(ClassChecker): o = Subclass('my_param') for value in NULLS: assert o.convert(value) is None + assert o.convert(None) is None for value in okay: assert o.convert(value) is value @@ -821,6 +822,7 @@ class test_Str(ClassChecker): assert e.name == 'my_str' assert e.index == 18 assert_equal(e.error, u'must be Unicode text') + assert o.convert(None) is None def test_rule_minlength(self): """ diff --git a/tests/test_ipalib/test_rpc.py b/tests/test_ipalib/test_rpc.py index 30175e3bf..351f483be 100644 --- a/tests/test_ipalib/test_rpc.py +++ b/tests/test_ipalib/test_rpc.py @@ -171,11 +171,13 @@ def test_xml_loads(): assert_equal(tup[0], params) # Test un-serializing an RPC response containing a Fault: - fault = Fault(69, unicode_str) - data = dumps(fault, methodresponse=True, allow_none=True) - e = raises(Fault, f, data) - assert e.faultCode == 69 - assert_equal(e.faultString, unicode_str) + for error in (unicode_str, u'hello'): + fault = Fault(69, error) + data = dumps(fault, methodresponse=True, allow_none=True, encoding='UTF-8') + e = raises(Fault, f, data) + assert e.faultCode == 69 + assert_equal(e.faultString, error) + assert type(e.faultString) is unicode class test_xmlclient(PluginTester): @@ -227,19 +229,19 @@ class test_xmlclient(PluginTester): context.xmlconn = DummyClass( ( 'user_add', - (rpc.xml_wrap(params),), + rpc.xml_wrap(params), {}, rpc.xml_wrap(result), ), ( 'user_add', - (rpc.xml_wrap(params),), + rpc.xml_wrap(params), {}, Fault(3007, u"'four' is required"), # RequirementError ), ( 'user_add', - (rpc.xml_wrap(params),), + rpc.xml_wrap(params), {}, Fault(700, u'no such error'), # There is no error 700 ), -- cgit