~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-26 19:26:33 UTC
  • mfrom: (1885 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1888.
  • Revision ID: john@arbash-meinel.com-20060726192633-576e4ffd1ef9d605
[merge] bzr.dev 1885

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
class BackupTransportHandler(Transport):
372
372
    """Test transport that works as a backup for the BadTransportHandler"""
373
373
    pass
 
374
 
 
375
 
 
376
class TestTransportImplementation(TestCaseInTempDir):
 
377
    """Implementation verification for transports.
 
378
    
 
379
    To verify a transport we need a server factory, which is a callable
 
380
    that accepts no parameters and returns an implementation of
 
381
    bzrlib.transport.Server.
 
382
    
 
383
    That Server is then used to construct transport instances and test
 
384
    the transport via loopback activity.
 
385
 
 
386
    Currently this assumes that the Transport object is connected to the 
 
387
    current working directory.  So that whatever is done 
 
388
    through the transport, should show up in the working 
 
389
    directory, and vice-versa. This is a bug, because its possible to have
 
390
    URL schemes which provide access to something that may not be 
 
391
    result in storage on the local disk, i.e. due to file system limits, or 
 
392
    due to it being a database or some other non-filesystem tool.
 
393
 
 
394
    This also tests to make sure that the functions work with both
 
395
    generators and lists (assuming iter(list) is effectively a generator)
 
396
    """
 
397
    
 
398
    def setUp(self):
 
399
        super(TestTransportImplementation, self).setUp()
 
400
        self._server = self.transport_server()
 
401
        self._server.setUp()
 
402
 
 
403
    def tearDown(self):
 
404
        super(TestTransportImplementation, self).tearDown()
 
405
        self._server.tearDown()
 
406
        
 
407
    def get_transport(self):
 
408
        """Return a connected transport to the local directory."""
 
409
        base_url = self._server.get_url()
 
410
        # try getting the transport via the regular interface:
 
411
        t = get_transport(base_url)
 
412
        if not isinstance(t, self.transport_class): 
 
413
            # we did not get the correct transport class type. Override the
 
414
            # regular connection behaviour by direct construction.
 
415
            t = self.transport_class(base_url)
 
416
        return t