~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib.tests import TestCase
26
26
from bzrlib.transport import (_get_protocol_handlers,
27
27
                              _get_transport_modules,
 
28
                              get_transport,
28
29
                              register_lazy_transport,
29
30
                              _set_protocol_handlers,
30
31
                              urlescape,
70
71
        self.assertEqual(True, transport.listable())
71
72
        self.assertEqual(False, transport.should_cache())
72
73
        self.assertEqual(False, transport.is_readonly())
 
74
        
 
75
        
 
76
class ReadonlyDecoratorTransportTest(TestCase):
 
77
    """Readonly decoration specific tests."""
 
78
 
 
79
    def test_local_parameters(self):
 
80
        import bzrlib.transport.readonly as readonly
 
81
        # connect to . in readonly mode
 
82
        transport = readonly.ReadonlyTransportDecorator('readonly+.')
 
83
        self.assertEqual(True, transport.listable())
 
84
        self.assertEqual(False, transport.should_cache())
 
85
        self.assertEqual(True, transport.is_readonly())
 
86
 
 
87
    def test_http_parameters(self):
 
88
        import bzrlib.transport.readonly as readonly
 
89
        from bzrlib.transport.http import HttpServer
 
90
        # connect to . via http which is not listable
 
91
        server = HttpServer()
 
92
        server.setUp()
 
93
        try:
 
94
            transport = get_transport('readonly+' + server.get_url())
 
95
            self.failUnless(isinstance(transport,
 
96
                                       readonly.ReadonlyTransportDecorator))
 
97
            self.assertEqual(False, transport.listable())
 
98
            self.assertEqual(True, transport.should_cache())
 
99
            self.assertEqual(True, transport.is_readonly())
 
100
        finally:
 
101
            server.tearDown()