~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

Add TestCaseWithTransport class that provides tests with read and write transport pairs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
                          _load_module_by_name,
25
25
                          TestCase,
26
26
                          TestCaseInTempDir,
 
27
                          TestCaseWithTransport,
27
28
                          TestSkipped,
28
29
                          TextTestRunner,
29
30
                          )
225
226
        self.assertEqual(tests[1].branch_format, formats[1])
226
227
        self.assertEqual(tests[1].transport_server, server1)
227
228
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
229
 
 
230
 
 
231
class TestTestCaseWithTransport(TestCaseWithTransport):
 
232
    """Tests for the convenience functions TestCaseWithTransport introduces."""
 
233
 
 
234
    def test_get_readonly_url_none(self):
 
235
        from bzrlib.transport import get_transport
 
236
        from bzrlib.transport.memory import MemoryServer
 
237
        from bzrlib.transport.readonly import ReadonlyTransportDecorator
 
238
        self.transport_server = MemoryServer
 
239
        self.transport_readonly_server = None
 
240
        # calling get_readonly_transport() constructs a decorator on the url
 
241
        # for the server
 
242
        url = self.get_readonly_url()
 
243
        t = get_transport(url)
 
244
        self.failUnless(isinstance(t, ReadonlyTransportDecorator))
 
245
 
 
246
    def test_get_readonly_url_http(self):
 
247
        from bzrlib.transport import get_transport
 
248
        from bzrlib.transport.local import LocalRelpathServer
 
249
        from bzrlib.transport.http import HttpServer, HttpTransport
 
250
        self.transport_server = LocalRelpathServer
 
251
        self.transport_readonly_server = HttpServer
 
252
        # calling get_readonly_transport() gives us a HTTP server instance.
 
253
        url = self.get_readonly_url()
 
254
        t = get_transport(url)
 
255
        self.failUnless(isinstance(t, HttpTransport))