187
187
class FakeMedium(medium.SmartClientMedium):
189
189
def __init__(self, client_calls, base):
190
self._remote_is_at_least_1_2 = True
190
medium.SmartClientMedium.__init__(self, base)
191
191
self._client_calls = client_calls
194
193
def disconnect(self):
195
194
self._client_calls.append(('disconnect medium',))
254
253
'xyz/', scheme + '//host/path', 'xyz/')
256
class Test_ClientMedium_remote_is_at_least(tests.TestCase):
257
"""Tests for the behaviour of client_medium.remote_is_at_least."""
259
def test_initially_unlimited(self):
260
"""A fresh medium assumes that the remote side supports all
263
client_medium = medium.SmartClientMedium('dummy base')
264
self.assertFalse(client_medium._is_remote_before((99, 99)))
266
def test__remember_remote_is_before(self):
267
"""Calling _remember_remote_is_before ratchets down the known remote
270
client_medium = medium.SmartClientMedium('dummy base')
271
# Mark the remote side as being less than 1.6. The remote side may
273
client_medium._remember_remote_is_before((1, 6))
274
self.assertTrue(client_medium._is_remote_before((1, 6)))
275
self.assertFalse(client_medium._is_remote_before((1, 5)))
276
# Calling _remember_remote_is_before again with a lower value works.
277
client_medium._remember_remote_is_before((1, 5))
278
self.assertTrue(client_medium._is_remote_before((1, 5)))
279
# You cannot call _remember_remote_is_before with a larger value.
281
AssertionError, client_medium._remember_remote_is_before, (1, 9))
257
284
class TestBzrDirOpenBranch(tests.TestCase):
259
286
def test_branch_present(self):
883
910
repo, client = self.setup_fake_client_and_repository(transport_path)
884
911
client.add_unknown_method_response('Repository,get_parent_map')
885
912
client.add_success_response_with_body('', 'ok')
886
self.assertTrue(client._medium._remote_is_at_least_1_2)
913
self.assertFalse(client._medium._is_remote_before((1, 2)))
887
914
rev_id = 'revision-id'
888
915
expected_deprecations = [
889
916
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
898
925
('quack/', ''))],
900
927
# The medium is now marked as being connected to an older server
901
self.assertFalse(client._medium._remote_is_at_least_1_2)
928
self.assertTrue(client._medium._is_remote_before((1, 2)))
903
930
def test_get_parent_map_fallback_parentless_node(self):
904
931
"""get_parent_map falls back to get_revision_graph on old servers. The
915
942
transport_path = 'quack'
916
943
repo, client = self.setup_fake_client_and_repository(transport_path)
917
944
client.add_success_response_with_body(rev_id, 'ok')
918
client._medium._remote_is_at_least_1_2 = False
945
client._medium._remember_remote_is_before((1, 2))
919
946
expected_deprecations = [
920
947
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
921
948
'in version 1.4.']