~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
603
603
 
604
604
 
605
605
class TestBranchControlGetBranchConf(tests.TestCaseWithMemoryTransport):
606
 
    """Test branch.control_files api munging...
607
 
 
608
 
    We special case RemoteBranch.control_files.get('branch.conf') to
609
 
    call a specific API so that RemoteBranch's can intercept configuration
610
 
    file reading, allowing them to signal to the client about things like
611
 
    'email is configured for commits'.
 
606
    """Getting the branch configuration should use an abstract method not vfs.
612
607
    """
613
608
 
614
609
    def test_get_branch_conf(self):
 
610
        raise tests.KnownFailure('branch.conf is not retrieved by get_config_file')
 
611
        # We should see that branch.get_config() does a single rpc to get the
 
612
        # remote configuration file, abstracting away where that is stored on
 
613
        # the server.  However at the moment it always falls back to using the
 
614
        # vfs, and this would need some changes in config.py.
 
615
 
615
616
        # in an empty branch we decode the response properly
616
 
        client = FakeClient([(('ok', ), 'config file body')], self.get_url())
 
617
        client = FakeClient([(('ok', ), '# config file body')], self.get_url())
617
618
        # we need to make a real branch because the remote_branch.control_files
618
619
        # will trigger _ensure_real.
619
620
        branch = self.make_branch('quack')
621
622
        # we do not want bzrdir to make any remote calls
622
623
        bzrdir = RemoteBzrDir(transport, _client=False)
623
624
        branch = RemoteBranch(bzrdir, None, _client=client)
624
 
        result = branch.control_files.get('branch.conf')
 
625
        config = branch.get_config()
625
626
        self.assertEqual(
626
627
            [('call_expecting_body', 'Branch.get_config_file', ('quack/',))],
627
628
            client._calls)
628
 
        self.assertEqual('config file body', result.read())
629
629
 
630
630
 
631
631
class TestBranchLockWrite(tests.TestCase):
829
829
        transport_path = 'quack'
830
830
        repo, client = self.setup_fake_client_and_repository(
831
831
            responses, transport_path)
 
832
        self.assertTrue(client._medium._remote_is_at_least_1_2)
832
833
        rev_id = 'revision-id'
833
834
        expected_deprecations = [
834
835
            'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
842
843
             ('call_expecting_body', 'Repository.get_revision_graph',
843
844
              ('quack/', ''))],
844
845
            client._calls)
 
846
        # The medium is now marked as being connected to an older server
 
847
        self.assertFalse(client._medium._remote_is_at_least_1_2)
 
848
 
 
849
    def test_get_parent_map_fallback_parentless_node(self):
 
850
        """get_parent_map falls back to get_revision_graph on old servers.  The
 
851
        results from get_revision_graph are tweaked to match the get_parent_map
 
852
        API.
 
853
 
 
854
        Specifically, a {key: ()} result from get_revision_graph means "no
 
855
        parents" for that key, which in get_parent_map results should be
 
856
        represented as {key: ('null:',)}.
 
857
 
 
858
        This is the test for https://bugs.launchpad.net/bzr/+bug/214894
 
859
        """
 
860
        rev_id = 'revision-id'
 
861
        responses = [(('ok',), rev_id)]
 
862
        transport_path = 'quack'
 
863
        repo, client = self.setup_fake_client_and_repository(
 
864
            responses, transport_path)
 
865
        client._medium._remote_is_at_least_1_2 = False
 
866
        expected_deprecations = [
 
867
            'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
 
868
            'in version 1.4.']
 
869
        parents = self.callDeprecated(
 
870
            expected_deprecations, repo.get_parent_map, [rev_id])
 
871
        self.assertEqual(
 
872
            [('call_expecting_body', 'Repository.get_revision_graph',
 
873
             ('quack/', ''))],
 
874
            client._calls)
 
875
        self.assertEqual({rev_id: ('null:',)}, parents)
845
876
 
846
877
    def test_get_parent_map_unexpected_response(self):
847
878
        responses = [