171
171
super(TestCaseWithWebserver, self).setUp()
172
172
self.transport_readonly_server = HttpServer
175
class TestCaseWithTwoWebservers(TestCaseWithWebserver):
176
"""A support class providinf readonly urls (on two servers) that are http://.
178
We setup two webservers to allows various tests involving
179
proxies or redirections from one server to the other.
182
super(TestCaseWithTwoWebservers, self).setUp()
183
self.transport_secondary_server = HttpServer
184
self.__secondary_server = None
186
def create_transport_secondary_server(self):
187
"""Create a transport server from class defined at init.
189
This is mostly a hook for daughter classes.
191
return self.transport_secondary_server()
193
def get_secondary_server(self):
194
"""Get the server instance for the secondary transport."""
195
if self.__secondary_server is None:
196
self.__secondary_server = self.create_transport_secondary_server()
197
self.__secondary_server.setUp()
198
# Note that addCleanup ensures that last added
199
# callables are called first. That will ensures that
200
# our cleanup is called before the other http server
201
# cleanup if we are created last and our cleanup is
202
# called after the other http server cleanup if we
204
self.addCleanup(self.__secondary_server.tearDown)
205
return self.__secondary_server
208
class FakeProxyRequestHandler(TestingHTTPRequestHandler):
209
"""Append a '-proxied' suffix to file served"""
211
def translate_path(self, path):
212
return TestingHTTPRequestHandler.translate_path(self,