Back to index

moin  1.9.0~rc2
test_xmlrpc.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - tests for the xmlrpc module
00004 
00005     @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from xmlrpclib import Fault
00010 
00011 from MoinMoin.user import User
00012 from MoinMoin.xmlrpc import XmlRpcBase
00013 
00014 
00015 def test_fault_serialization(request):
00016     """test MoinMoin.xmlrpc.xmlrpc_system_multicall Fault serialization"""
00017 
00018     def xmlrpc_return_fault():
00019         return Fault(666, "Fault description")
00020 
00021     xmlrpc = XmlRpcBase(request)
00022     xmlrpc.xmlrpc_return_fault = xmlrpc_return_fault
00023     args = [{'methodName': 'return_fault', 'params': []}]
00024 
00025     print """If a XML RPC method returns a Fault, we should get a failure response
00026     instead of a serialized Fault, as it happened in the past. See revision
00027     8b7d6d70fc95 for details"""
00028 
00029     result = xmlrpc.xmlrpc_system_multicall(args)
00030     assert type(result[0]) is dict
00031     assert result[0].has_key("faultCode") and result[0].has_key("faultString")
00032 
00033 def test_getAuthToken(request):
00034     """ Tests if getAuthToken passes without crashing """
00035     xmlrpc = XmlRpcBase(request)
00036     assert xmlrpc.xmlrpc_getAuthToken("Foo", "bar") == ""
00037 
00038 coverage_modules = ['MoinMoin.xmlrpc']
00039