/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: 2009-06-02 06:01:55 UTC
  • mto: This revision was merged to the branch mainline in revision 4401.
  • Revision ID: andrew.bennetts@canonical.com-20090602060155-ib17vor7jn1555qh
Translate ErrorFromSmartServer in RemoteBzrDirFormat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
741
741
        self.assertEqual(network_name, repo._format.network_name())
742
742
 
743
743
 
 
744
class TestBzrDirFormatInitializeEx(TestRemote):
 
745
 
 
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'),
 
756
            'success',
 
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()
 
765
 
 
766
    def test_error(self):
 
767
        """Error responses are translated, e.g. 'PermissionDenied' raises the
 
768
        corresponding error from the client.
 
769
        """
 
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'),
 
778
            'error',
 
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()
 
789
 
 
790
 
744
791
class OldSmartClient(object):
745
792
    """A fake smart client for test_old_version that just returns a version one
746
793
    response to the 'hello' (query version) command.