~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtransport.py

Merge from mpool.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os
19
19
from cStringIO import StringIO
20
20
 
21
 
from bzrlib.errors import NoSuchFile, FileExists, TransportNotPossible
 
21
from bzrlib.errors import (NoSuchFile, FileExists, TransportNotPossible,
 
22
                           ConnectionError)
22
23
from bzrlib.selftest import TestCase, TestCaseInTempDir
23
24
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
24
25
from bzrlib.transport import memory, urlescape
463
464
        # TODO: Test Transport.move
464
465
        pass
465
466
 
 
467
    def test_connection_error(self):
 
468
        """ConnectionError is raised when connection is impossible"""
 
469
        if not hasattr(self, "get_bogus_transport"):
 
470
            return
 
471
        t = self.get_bogus_transport()
 
472
        self.assertRaises(ConnectionError, t.get, '.bzr/branch')
466
473
 
 
474
        
467
475
class LocalTransportTest(TestCaseInTempDir, TestTransportMixIn):
468
476
    def get_transport(self):
469
477
        from bzrlib.transport.local import LocalTransport
479
487
        url = self.get_remote_url('.')
480
488
        return HttpTransport(url)
481
489
 
 
490
    def get_bogus_transport(self):
 
491
        from bzrlib.transport.http import HttpTransport
 
492
        return HttpTransport('http://jasldkjsalkdjalksjdkljasd')
 
493
 
482
494
 
483
495
class TestMemoryTransport(TestCase):
484
496
 
569
581
        transport.put('bar', StringIO('phowar'))
570
582
        self.assertEqual(7, transport.stat('foo').st_size)
571
583
        self.assertEqual(6, transport.stat('bar').st_size)
572
 
        
 
584