Esempio n. 1
0
 def test_xmlrpc_pack_unpack(self):
     params = (1,2,['a','b'])
     marshaled = xmlrpc.client.dumps(params)
     tojid = '*****@*****.**'
     typ = 'set'
     iq = rpc.make_iq(tojid, typ, marshaled, msgid=None)
     return_xml = rpc.extract_iq(iq)
     unmarshaled = xmlrpc.client.loads(return_xml)
     # loads returns (params, methodname)
     self.failUnlessEqual(unmarshaled[0], params)
Esempio n. 2
0
 def test_xmlrpcbot(self):
    """
    Basic test of the XML-RPC class
    """
    bot = rpc.XmlRpcBot()
    def add(x, y):
      return x+y
    bot.register_function(add)
    params = xmlrpc.client.dumps((1,2),'add')
    msg = rpc.make_iq('*****@*****.**', 'set', params)
    conn = fake_conn()
    self.failUnlessRaises(xmpp.NodeProcessed, bot.bot_dispatcher, conn, msg)
    self.failUnless(len(conn.messages) == 1)
    result_xml = rpc.extract_iq(conn.messages[0])
    result_tuple = xmlrpc.client.loads(result_xml)
    result = result_tuple[0][0]
    self.failUnlessEqual(3, result)