~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtransport.py

  • Committer: Aaron Bentley
  • Date: 2005-11-15 21:09:09 UTC
  • mto: (1185.33.17 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 1509.
  • Revision ID: abentley@panoramicfeedback.com-20051115210909-65710970107c20a3
Throw ConnectionError instead of NoSuchFile except when we get a 404

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
450
451
        # TODO: Test Transport.move
451
452
        pass
452
453
 
 
454
    def test_connection_error(self):
 
455
        """ConnectionError is raised when connection is impossible"""
 
456
        if not hasattr(self, "get_bogus_transport"):
 
457
            return
 
458
        t = self.get_bogus_transport()
 
459
        self.assertRaises(ConnectionError, t.get, '.bzr/branch')
453
460
 
 
461
        
454
462
class LocalTransportTest(TestCaseInTempDir, TestTransportMixIn):
455
463
    def get_transport(self):
456
464
        from bzrlib.transport.local import LocalTransport
466
474
        url = self.get_remote_url('.')
467
475
        return HttpTransport(url)
468
476
 
 
477
    def get_bogus_transport(self):
 
478
        from bzrlib.transport.http import HttpTransport
 
479
        return HttpTransport('http://www.example.com')
 
480
 
469
481
 
470
482
class TestMemoryTransport(TestCase):
471
483
 
556
568
        transport.put('bar', StringIO('phowar'))
557
569
        self.assertEqual(7, transport.stat('foo').st_size)
558
570
        self.assertEqual(6, transport.stat('bar').st_size)
559
 
        
 
571