Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 804

Show
Ignore:
Timestamp:
11/09/05 22:03:37
Author:
dowski
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/test_xmlrpc_filter.py

    r778 r804  
    6767               {'xmlRpcFilter.on':True} 
    6868              }) 
     69 
    6970         
     71class ServerlessProxy(object): 
     72    """An xmlrpc proxy for the test suite's 'serverless' tests.""" 
     73    def __init__(self, webcase, url): 
     74        self._webcase = webcase 
     75        self.url = url 
     76 
     77    def __getattr__(self, attr, *args): 
     78        def xmlrpc_method(*args): 
     79            args = tuple(args) 
     80            body = xmlrpclib.dumps(args, attr) 
     81            cl = len(body) 
     82            headers = [('Content-Type', 'text/xml'), ('Content-Length', str(cl))] 
     83            self._webcase.getPage(self.url, headers=headers, method="POST", body=body) 
     84            return xmlrpclib.loads("".join(self._webcase.body))[0][0]             
     85        return xmlrpc_method 
    7086 
    7187 
    7288class XmlRpcFilterTest(helper.CPWebCase): 
    7389    def testXmlRpcFilter(self): 
    74          
    75         proxy = xmlrpclib.ServerProxy('http://localhost:%s/xmlrpc/' % (self.PORT)) 
    7690 
     91        # load the appropriate xmlrpc proxy 
     92        if cherrypy.server.httpserver is None:         
     93            proxy = ServerlessProxy(self, 'http://localhost:%s/xmlrpc/' % (self.PORT)) 
     94        else: 
     95            proxy = xmlrpclib.ServerProxy('http://localhost:%s/xmlrpc/' % (self.PORT)) 
     96 
     97        # begin the tests ... 
    7798        self.assertEqual(proxy.return_single_item_list(), 
    7899                         [42] 
     100                         ) 
     101        self.assertNotEqual(proxy.return_single_item_list(), 
     102                         'one bazillion' 
    79103                         ) 
    80104        self.assertEqual(proxy.return_string(), 

Hosted by WebFaction

Log in as guest/cpguest to create tickets