~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_utils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-14 05:49:27 UTC
  • mfrom: (4476.3.86 inventory-delta)
  • Revision ID: pqm@pqm.ubuntu.com-20090814054927-k0k18dn46ax4b91f
(andrew) Add inventory-delta streaming for cross-format fetch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
58
58
        """Hand the request off to a smart server instance."""
59
59
        backing = get_transport(self.server.test_case_server._home_dir)
60
60
        chroot_server = chroot.ChrootServer(backing)
61
 
        chroot_server.start_server()
 
61
        chroot_server.setUp()
62
62
        try:
63
63
            t = get_transport(chroot_server.get_url())
64
64
            self.do_POST_inner(t)
65
65
        finally:
66
 
            chroot_server.stop_server()
 
66
            chroot_server.tearDown()
67
67
 
68
68
    def do_POST_inner(self, chrooted_transport):
69
69
        self.send_response(200)
106
106
    one. This will currently fail if the primary transport is not
107
107
    backed by regular disk files.
108
108
    """
109
 
 
110
 
    # This can be overriden or parametrized by daughter clasess if needed, but
111
 
    # it must exist so that the create_transport_readonly_server() method can
112
 
    # propagate it.
113
 
    _protocol_version = None
114
 
 
115
109
    def setUp(self):
116
110
        super(TestCaseWithWebserver, self).setUp()
117
111
        self.transport_readonly_server = http_server.HttpServer
118
112
 
119
 
    def create_transport_readonly_server(self):
120
 
        return self.transport_readonly_server(
121
 
            protocol_version=self._protocol_version)
122
 
 
123
113
 
124
114
class TestCaseWithTwoWebservers(TestCaseWithWebserver):
125
115
    """A support class providing readonly urls on two servers that are http://.
137
127
 
138
128
        This is mostly a hook for daughter classes.
139
129
        """
140
 
        return self.transport_secondary_server(
141
 
            protocol_version=self._protocol_version)
 
130
        return self.transport_secondary_server()
142
131
 
143
132
    def get_secondary_server(self):
144
133
        """Get the server instance for the secondary transport."""
145
134
        if self.__secondary_server is None:
146
135
            self.__secondary_server = self.create_transport_secondary_server()
147
 
            self.start_server(self.__secondary_server)
 
136
            self.__secondary_server.setUp()
 
137
            self.addCleanup(self.__secondary_server.tearDown)
148
138
        return self.__secondary_server
149
139
 
150
140
 
229
219
   def create_transport_secondary_server(self):
230
220
       """Create the secondary server redirecting to the primary server"""
231
221
       new = self.get_readonly_server()
232
 
       redirecting = HTTPServerRedirecting(
233
 
           protocol_version=self._protocol_version)
 
222
       redirecting = HTTPServerRedirecting()
234
223
       redirecting.redirect_to(new.host, new.port)
235
224
       return redirecting
236
225