import test
test.prefer_parent_path()

import xmlrpclib
import cherrypy

class Root:
    def index(self):
        return "I'm a standard index!"
    index.exposed = True

    
class XmlRpc:
    def return_single_item_list(self):
        return [42]
    return_single_item_list.exposed = True
    
    def return_string(self):
        return "here is a string"
    return_string.exposed = True
    
    def return_tuple(self):
        return ('here', 'is', 1, 'tuple')
    return_tuple.exposed = True
    
    def return_dict(self):
        return dict(a=1, b=2, c=3)
    return_dict.exposed = True
    
    def return_composite(self):
        return dict(a=1,z=26), 'hi', ['welcome', 'friend']
    return_composite.exposed = True

    def return_int(self):
        return 42
    return_int.exposed = True

    def return_float(self):
        return 3.14
    return_float.exposed = True

    def return_datetime(self):
        return xmlrpclib.DateTime((2003, 10, 7, 8, 1, 0, 1, 280, -1))
    return_datetime.exposed = True

    def return_boolean(self):
        return True
    return_boolean.exposed = True

    def test_argument_passing(self, num):
        return num * 2
    test_argument_passing.exposed = True

cherrypy.root = Root()
cherrypy.root.xmlrpc = XmlRpc()

import helper
        
cherrypy.config.update({
    'global': {'server.logToScreen': False,
               'server.environment': 'production',
               'server.showTracebacks': True,
               'server.socketHost': helper.CPWebCase.HOST,
               'server.socketPort': helper.CPWebCase.PORT,
               },
    '/xmlrpc':
               {'xmlRpcFilter.on':True}
              })
        


class XmlRpcFilterTest(helper.CPWebCase):
    def testXmlRpcFilter(self):
        
        proxy = xmlrpclib.ServerProxy('http://localhost:%s/xmlrpc/' % (self.PORT))

        self.assertEqual(proxy.return_single_item_list(),
                         [42]
                         )
        self.assertEqual(proxy.return_string(),
                         "here is a string"
                         )
        self.assertEqual(proxy.return_tuple(),
                         list(('here', 'is', 1, 'tuple'))
                         )
        self.assertEqual(proxy.return_dict(),
                         {'a': 1, 'c': 3, 'b': 2}
                         )
        self.assertEqual(proxy.return_composite(),
                         [{'a': 1, 'z': 26}, 'hi', ['welcome', 'friend']]
                         )
        self.assertEqual(proxy.return_int(),
                         42
                         )
        self.assertEqual(proxy.return_float(),
                               3.14
                        )
        self.assertEqual(proxy.return_datetime(),
                         xmlrpclib.DateTime((2003, 10, 7, 8, 1, 0, 1, 280, -1))
                         )
        self.assertEqual(proxy.return_boolean(),
                         True
                         )
        self.assertEqual(proxy.test_argument_passing(22), 
                        22 * 2
                        )


if __name__ == '__main__':
    from cherrypy import _cpwsgi
    serverClass = _cpwsgi.WSGIServer
    helper.testmain(serverClass)
    

@@ -1662,16 +1662,17 @@
      %7D)%0A
+%0A
         
@@ -1672,16 +1672,667 @@
        %0A
+class ServerlessProxy(object):%0A    %22%22%22An xmlrpc proxy for the test suite's 'serverless' tests.%22%22%22%0A    def __init__(self, webcase, url):%0A        self._webcase = webcase%0A        self.url = url%0A%0A    def __getattr__(self, attr, *args):%0A        def xmlrpc_method(*args):%0A            args = tuple(args)%0A            body = xmlrpclib.dumps(args, attr)%0A            cl = len(body)%0A            headers = %5B('Content-Type', 'text/xml'), ('Content-Length', str(cl))%5D%0A            self._webcase.getPage(self.url, headers=headers, method=%22POST%22, body=body)%0A            return xmlrpclib.loads(%22%22.join(self._webcase.body))%5B0%5D%5B0%5D            %0A        return xmlrpc_method%0A
 %0A%0Aclass 
@@ -2399,24 +2399,25 @@
 (self):%0A
+%0A
         
 %0A       
@@ -2400,33 +2400,228 @@
 self):%0A%0A        
-%0A
+# load the appropriate xmlrpc proxy%0A        if cherrypy.server.httpserver is None:        %0A            proxy = ServerlessProxy(self, 'http://localhost:%25s/xmlrpc/' %25 (self.PORT))%0A        else:%0A    
         proxy = 
@@ -2688,16 +2688,46 @@
 PORT))%0A%0A
+        # begin the tests ...%0A
         
@@ -2825,32 +2825,161 @@
               )%0A
+        self.assertNotEqual(proxy.return_single_item_list(),%0A                         'one bazillion'%0A                         )%0A
         self.ass

Fix for #377. Added a 'ServerlessProxy' class to deal with running the xmlrpcfilter tests without a webserver running.