741
741
self.assertEqual(network_name, repo._format.network_name())
744
class TestBzrDirFormatInitializeEx(TestRemote):
746
def test_success(self):
747
"""Simple test for typical successful call."""
748
fmt = bzrdir.RemoteBzrDirFormat()
749
default_format_name = BzrDirFormat.get_default_format().network_name()
750
transport = self.get_transport()
751
client = FakeClient(transport.base)
752
client.add_expected_call(
753
'BzrDirFormat.initialize_ex',
754
(default_format_name, 'path', 'False', 'False', 'False', '',
755
'', '', '', 'False'),
757
('.', 'no', 'no', 'yes', 'repo fmt', 'repo bzrdir fmt',
758
'bzrdir fmt', 'False', '', '', 'repo lock token'))
759
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
760
# it's currently hard to test that without supplying a real remote
761
# transport connected to a real server.
762
result = fmt._initialize_on_transport_ex_rpc(client, 'path',
763
transport, False, False, False, None, None, None, None, False)
764
client.finished_test()
766
def test_error(self):
767
"""Error responses are translated, e.g. 'PermissionDenied' raises the
768
corresponding error from the client.
770
fmt = bzrdir.RemoteBzrDirFormat()
771
default_format_name = BzrDirFormat.get_default_format().network_name()
772
transport = self.get_transport()
773
client = FakeClient(transport.base)
774
client.add_expected_call(
775
'BzrDirFormat.initialize_ex',
776
(default_format_name, 'path', 'False', 'False', 'False', '',
777
'', '', '', 'False'),
779
('PermissionDenied', 'path', 'extra info'))
780
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
781
# it's currently hard to test that without supplying a real remote
782
# transport connected to a real server.
783
err = self.assertRaises(errors.PermissionDenied,
784
fmt._initialize_on_transport_ex_rpc, client, 'path', transport,
785
False, False, False, None, None, None, None, False)
786
self.assertEqual('path', err.path)
787
self.assertEqual(': extra info', err.extra)
788
client.finished_test()
790
def test_error_from_real_server(self):
791
"""Integration test for error translation."""
792
transport = self.make_smart_server('foo')
793
transport = transport.clone('no-such-path')
794
fmt = bzrdir.RemoteBzrDirFormat()
795
err = self.assertRaises(errors.NoSuchFile,
796
fmt.initialize_on_transport_ex, transport, create_prefix=False)
744
799
class OldSmartClient(object):
745
800
"""A fake smart client for test_old_version that just returns a version one
746
801
response to the 'hello' (query version) command.