/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Andrew Bennetts
  • Date: 2007-04-30 02:02:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2468.
  • Revision ID: andrew.bennetts@canonical.com-20070430020205-ensbvu0t14yb3tk4
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from bzrlib.smart import server, medium
45
45
from bzrlib.smart.client import _SmartClient
46
46
from bzrlib.transport.memory import MemoryTransport
 
47
from bzrlib.transport.remote import RemoteTransport
47
48
 
48
49
 
49
50
class BasicRemoteObjectTests(tests.TestCaseWithTransport):
60
61
        self.transport.disconnect()
61
62
        tests.TestCaseWithTransport.tearDown(self)
62
63
 
63
 
    def test_is_readonly(self):
64
 
        # XXX: this is a poor way to test RemoteTransport, but currently there's
65
 
        # no easy way to substitute in a fake client on a transport like we can
66
 
        # with RemoteBzrDir/Branch/Repository.
67
 
        self.assertEqual(self.transport.is_readonly(), False)
68
 
 
69
64
    def test_create_remote_bzrdir(self):
70
65
        b = remote.RemoteBzrDir(self.transport)
71
66
        self.assertIsInstance(b, BzrDir)
404
399
            client._calls)
405
400
 
406
401
 
 
402
class TestTransportIsReadonly(tests.TestCase):
 
403
 
 
404
    def test_true(self):
 
405
        client = FakeClient([(('yes',), '')])
 
406
        transport = RemoteTransport('bzr://example.com/', medium=False,
 
407
                                    _client=client)
 
408
        self.assertEqual(True, transport.is_readonly())
 
409
        self.assertEqual(
 
410
            [('call', 'Transport.is_readonly', ())],
 
411
            client._calls)
 
412
 
 
413
    def test_false(self):
 
414
        client = FakeClient([(('no',), '')])
 
415
        transport = RemoteTransport('bzr://example.com/', medium=False,
 
416
                                    _client=client)
 
417
        self.assertEqual(False, transport.is_readonly())
 
418
        self.assertEqual(
 
419
            [('call', 'Transport.is_readonly', ())],
 
420
            client._calls)
 
421
 
 
422
    def test_error_from_old_server(self):
 
423
        """bzr 0.15 and earlier servers don't recognise the is_readonly verb.
 
424
        
 
425
        Clients should treat it as a "no" response, because is_readonly is only
 
426
        advisory anyway (a transport could be read-write, but then the
 
427
        underlying filesystem could be readonly anyway).
 
428
        """
 
429
        client = FakeClient([(
 
430
            ('error', "Generic bzr smart protocol error: "
 
431
                      "bad request 'Transport.is_readonly'"), '')])
 
432
        transport = RemoteTransport('bzr://example.com/', medium=False,
 
433
                                    _client=client)
 
434
        self.assertEqual(False, transport.is_readonly())
 
435
        self.assertEqual(
 
436
            [('call', 'Transport.is_readonly', ())],
 
437
            client._calls)
 
438
 
 
439
 
407
440
class TestRemoteRepository(tests.TestCase):
408
441
    """Base for testing RemoteRepository protocol usage.
409
442