/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: Martin Pool
  • Date: 2009-06-19 09:06:56 UTC
  • mfrom: (4463 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4464.
  • Revision ID: mbp@sourcefrog.net-20090619090656-d5weqeecyscv8kqp
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    condition_isinstance,
59
59
    split_suite_by_condition,
60
60
    multiply_tests,
 
61
    KnownFailure,
61
62
    )
62
63
from bzrlib.transport import get_transport, http
63
64
from bzrlib.transport.memory import MemoryTransport
153
154
        r = BzrDir.open_from_transport(t.clone('stackable')).open_repository()
154
155
        self.assertTrue(r._format.supports_external_lookups)
155
156
 
 
157
    def test_remote_branch_set_append_revisions_only(self):
 
158
        # Make a format 1.9 branch, which supports append_revisions_only
 
159
        branch = self.make_branch('branch', format='1.9')
 
160
        config = branch.get_config()
 
161
        branch.set_append_revisions_only(True)
 
162
        self.assertEqual(
 
163
            'True', config.get_user_option('append_revisions_only'))
 
164
        branch.set_append_revisions_only(False)
 
165
        self.assertEqual(
 
166
            'False', config.get_user_option('append_revisions_only'))
 
167
 
 
168
    def test_remote_branch_set_append_revisions_only_upgrade_reqd(self):
 
169
        branch = self.make_branch('branch', format='knit')
 
170
        config = branch.get_config()
 
171
        self.assertRaises(
 
172
            errors.UpgradeRequired, branch.set_append_revisions_only, True)
 
173
 
156
174
 
157
175
class FakeProtocol(object):
158
176
    """Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
750
768
        transport = self.get_transport()
751
769
        client = FakeClient(transport.base)
752
770
        client.add_expected_call(
753
 
            'BzrDirFormat.initialize_ex',
 
771
            'BzrDirFormat.initialize_ex_1.16',
754
772
                (default_format_name, 'path', 'False', 'False', 'False', '',
755
773
                 '', '', '', 'False'),
756
774
            'success',
772
790
        transport = self.get_transport()
773
791
        client = FakeClient(transport.base)
774
792
        client.add_expected_call(
775
 
            'BzrDirFormat.initialize_ex',
 
793
            'BzrDirFormat.initialize_ex_1.16',
776
794
                (default_format_name, 'path', 'False', 'False', 'False', '',
777
795
                 '', '', '', 'False'),
778
796
            'error',
2018
2036
        self.assertEqual(('AnUnexpectedError',), e.error_tuple)
2019
2037
 
2020
2038
 
 
2039
class TestRepositoryGetRevIdForRevno(TestRemoteRepository):
 
2040
 
 
2041
    def test_ok(self):
 
2042
        repo, client = self.setup_fake_client_and_repository('quack')
 
2043
        client.add_expected_call(
 
2044
            'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
 
2045
            'success', ('ok', 'rev-five'))
 
2046
        result = repo.get_rev_id_for_revno(5, (42, 'rev-foo'))
 
2047
        self.assertEqual((True, 'rev-five'), result)
 
2048
        client.finished_test()
 
2049
 
 
2050
    def test_history_incomplete(self):
 
2051
        repo, client = self.setup_fake_client_and_repository('quack')
 
2052
        client.add_expected_call(
 
2053
            'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
 
2054
            'success', ('history-incomplete', 10, 'rev-ten'))
 
2055
        result = repo.get_rev_id_for_revno(5, (42, 'rev-foo'))
 
2056
        self.assertEqual((False, (10, 'rev-ten')), result)
 
2057
        client.finished_test()
 
2058
 
 
2059
    def test_history_incomplete_with_fallback(self):
 
2060
        """A 'history-incomplete' response causes the fallback repository to be
 
2061
        queried too, if one is set.
 
2062
        """
 
2063
        # Make a repo with a fallback repo, both using a FakeClient.
 
2064
        format = remote.response_tuple_to_repo_format(
 
2065
            ('yes', 'no', 'yes', 'fake-network-name'))
 
2066
        repo, client = self.setup_fake_client_and_repository('quack')
 
2067
        repo._format = format
 
2068
        fallback_repo, ignored = self.setup_fake_client_and_repository(
 
2069
            'fallback')
 
2070
        fallback_repo._client = client
 
2071
        repo.add_fallback_repository(fallback_repo)
 
2072
        # First the client should ask the primary repo
 
2073
        client.add_expected_call(
 
2074
            'Repository.get_rev_id_for_revno', ('quack/', 1, (42, 'rev-foo')),
 
2075
            'success', ('history-incomplete', 2, 'rev-two'))
 
2076
        # Then it should ask the fallback, using revno/revid from the
 
2077
        # history-incomplete response as the known revno/revid.
 
2078
        client.add_expected_call(
 
2079
            'Repository.get_rev_id_for_revno',('fallback/', 1, (2, 'rev-two')),
 
2080
            'success', ('ok', 'rev-one'))
 
2081
        result = repo.get_rev_id_for_revno(1, (42, 'rev-foo'))
 
2082
        self.assertEqual((True, 'rev-one'), result)
 
2083
        client.finished_test()
 
2084
 
 
2085
    def test_nosuchrevision(self):
 
2086
        # 'nosuchrevision' is returned when the known-revid is not found in the
 
2087
        # remote repo.  The client translates that response to NoSuchRevision.
 
2088
        repo, client = self.setup_fake_client_and_repository('quack')
 
2089
        client.add_expected_call(
 
2090
            'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
 
2091
            'error', ('nosuchrevision', 'rev-foo'))
 
2092
        self.assertRaises(
 
2093
            errors.NoSuchRevision,
 
2094
            repo.get_rev_id_for_revno, 5, (42, 'rev-foo'))
 
2095
        client.finished_test()
 
2096
 
 
2097
 
2021
2098
class TestRepositoryIsShared(TestRemoteRepository):
2022
2099
 
2023
2100
    def test_is_shared(self):