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.assertTrue(client_medium._is_remote_at_least((99, 99)))
266
def test__remote_is_not(self):
267
"""Calling _remote_is_not ratchets down the known remote version."""
268
client_medium = medium.SmartClientMedium('dummy base')
269
# Mark the remote side as being less than 1.6. The remote side may
271
client_medium._remote_is_not((1, 6))
272
self.assertFalse(client_medium._is_remote_at_least((1, 6)))
273
self.assertTrue(client_medium._is_remote_at_least((1, 5)))
274
# Calling _remote_is_not again with a lower value works.
275
client_medium._remote_is_not((1, 5))
276
self.assertFalse(client_medium._is_remote_at_least((1, 5)))
277
# You cannot call _remote_is_not with a larger value.
279
AssertionError, client_medium._remote_is_not, (1, 9))
257
282
class TestBzrDirOpenBranch(tests.TestCase):
259
284
def test_branch_present(self):
883
908
repo, client = self.setup_fake_client_and_repository(transport_path)
884
909
client.add_unknown_method_response('Repository,get_parent_map')
885
910
client.add_success_response_with_body('', 'ok')
886
self.assertTrue(client._medium._remote_is_at_least_1_2)
911
self.assertTrue(client._medium._is_remote_at_least((1, 2)))
887
912
rev_id = 'revision-id'
888
913
expected_deprecations = [
889
914
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
898
923
('quack/', ''))],
900
925
# The medium is now marked as being connected to an older server
901
self.assertFalse(client._medium._remote_is_at_least_1_2)
926
self.assertFalse(client._medium._is_remote_at_least((1, 2)))
903
928
def test_get_parent_map_fallback_parentless_node(self):
904
929
"""get_parent_map falls back to get_revision_graph on old servers. The
915
940
transport_path = 'quack'
916
941
repo, client = self.setup_fake_client_and_repository(transport_path)
917
942
client.add_success_response_with_body(rev_id, 'ok')
918
client._medium._remote_is_at_least_1_2 = False
943
client._medium._remote_is_not((1, 2))
919
944
expected_deprecations = [
920
945
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
921
946
'in version 1.4.']