On Wed, Mar 25, 2009 at 2:18 PM, Bryan <
brya...@gmail.com> wrote:
>
> I could simply make calls to the controller itself, but I want to
> include the transport layer in the tests, that way I can catch errors
> in badly formed xmlrpc requests and responses.
>
oh sorry I see what you mean now. You are connecting to the xmlrpc
server that you implemented using XMLRPCController.
> Let me ask a more general question:
> When pylons unit tests run, is the test instance actually bound to an
> ip and port?
Nope, in the tests a "server" is not running at all. it is not
attached to an ip or port. What you have instead is a WSGI app that
has been loaded into a WebTest instance; all this happens in-process.
You could take another approach and use wsgi_intercept:
http://code.google.com/p/wsgi-intercept/ ... however ... I don't
recall how to intercept something that uses httplib (which is what
drives xmlrpclib). d'oh
My best suggestion is to write a custom Transport :
class WSGIAppTransport(xmlrpclib.Transport):
def make_connection(self, host):
host, extra_headers, x509 = self.get_host_info(host)
from pylons.test import pylonsapp
return WSGILikeHTTP(host, pylonsapp)
# then use it in your test :
from xmlrpclib import ServerProxy
server = ServerProxy('http://ipaddress:port/xmlrpc/',
transport=WSGIAppTransport())
The implementation of WSGILikeHTTP would need to re-route all http
requests to your WSGI pylonsapp which is created in
yourapp/tests/__init__.py . You'd have to implement all the methods
from httplib.HTTP like putrequest() and getreply() etc.
... or maybe there is an easier way? not sure. Good question.
>
> In my test.ini I have a server host and port defined, are those used
> at all when unit tests are run? How can paste.fixture make requests
> to my regular controllers, but I can't make an xmlrpc request?
the reason is because paste.fixture (and WebTest) are designed to
simulate a wsgi server environment not an xmlrpc server environment.