~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/decorator.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
            return None
178
178
 
179
179
 
180
 
class DecoratorServer(Server):
181
 
    """Server for the TransportDecorator for testing with.
182
 
 
183
 
    To use this when subclassing TransportDecorator, override override the
184
 
    get_decorator_class method.
185
 
    """
186
 
 
187
 
    def start_server(self, server=None):
188
 
        """See bzrlib.transport.Server.start_server.
189
 
 
190
 
        :server: decorate the urls given by server. If not provided a
191
 
        LocalServer is created.
192
 
        """
193
 
        if server is not None:
194
 
            self._made_server = False
195
 
            self._server = server
196
 
        else:
197
 
            from bzrlib.transport.local import LocalURLServer
198
 
            self._made_server = True
199
 
            self._server = LocalURLServer()
200
 
            self._server.start_server()
201
 
 
202
 
    def stop_server(self):
203
 
        if self._made_server:
204
 
            self._server.stop_server()
205
 
 
206
 
    def get_decorator_class(self):
207
 
        """Return the class of the decorators we should be constructing."""
208
 
        raise NotImplementedError(self.get_decorator_class)
209
 
 
210
 
    def get_url_prefix(self):
211
 
        """What URL prefix does this decorator produce?"""
212
 
        return self.get_decorator_class()._get_url_prefix()
213
 
 
214
 
    def get_bogus_url(self):
215
 
        """See bzrlib.transport.Server.get_bogus_url."""
216
 
        return self.get_url_prefix() + self._server.get_bogus_url()
217
 
 
218
 
    def get_url(self):
219
 
        """See bzrlib.transport.Server.get_url."""
220
 
        return self.get_url_prefix() + self._server.get_url()
221
 
 
222
 
 
223
180
def get_test_permutations():
224
181
    """Return the permutations to be used in testing.
225
182