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
49
50
class BasicRemoteObjectTests(tests.TestCaseWithTransport):
60
61
self.transport.disconnect()
61
62
tests.TestCaseWithTransport.tearDown(self)
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)
69
64
def test_create_remote_bzrdir(self):
70
65
b = remote.RemoteBzrDir(self.transport)
71
66
self.assertIsInstance(b, BzrDir)
402
class TestTransportIsReadonly(tests.TestCase):
405
client = FakeClient([(('yes',), '')])
406
transport = RemoteTransport('bzr://example.com/', medium=False,
408
self.assertEqual(True, transport.is_readonly())
410
[('call', 'Transport.is_readonly', ())],
413
def test_false(self):
414
client = FakeClient([(('no',), '')])
415
transport = RemoteTransport('bzr://example.com/', medium=False,
417
self.assertEqual(False, transport.is_readonly())
419
[('call', 'Transport.is_readonly', ())],
422
def test_error_from_old_server(self):
423
"""bzr 0.15 and earlier servers don't recognise the is_readonly verb.
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).
429
client = FakeClient([(
430
('error', "Generic bzr smart protocol error: "
431
"bad request 'Transport.is_readonly'"), '')])
432
transport = RemoteTransport('bzr://example.com/', medium=False,
434
self.assertEqual(False, transport.is_readonly())
436
[('call', 'Transport.is_readonly', ())],
407
440
class TestRemoteRepository(tests.TestCase):
408
441
"""Base for testing RemoteRepository protocol usage.