187
187
class FakeMedium(medium.SmartClientMedium):
189
189
def __init__(self, client_calls, base):
190
medium.SmartClientMedium.__init__(self, base)
190
self._remote_is_at_least_1_2 = True
191
191
self._client_calls = client_calls
193
194
def disconnect(self):
194
195
self._client_calls.append(('disconnect medium',))
253
254
'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))
282
257
class TestBzrDirOpenBranch(tests.TestCase):
284
259
def test_branch_present(self):
908
883
repo, client = self.setup_fake_client_and_repository(transport_path)
909
884
client.add_unknown_method_response('Repository,get_parent_map')
910
885
client.add_success_response_with_body('', 'ok')
911
self.assertTrue(client._medium._is_remote_at_least((1, 2)))
886
self.assertTrue(client._medium._remote_is_at_least_1_2)
912
887
rev_id = 'revision-id'
913
888
expected_deprecations = [
914
889
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
923
898
('quack/', ''))],
925
900
# The medium is now marked as being connected to an older server
926
self.assertFalse(client._medium._is_remote_at_least((1, 2)))
901
self.assertFalse(client._medium._remote_is_at_least_1_2)
928
903
def test_get_parent_map_fallback_parentless_node(self):
929
904
"""get_parent_map falls back to get_revision_graph on old servers. The
940
915
transport_path = 'quack'
941
916
repo, client = self.setup_fake_client_and_repository(transport_path)
942
917
client.add_success_response_with_body(rev_id, 'ok')
943
client._medium._remote_is_not((1, 2))
918
client._medium._remote_is_at_least_1_2 = False
944
919
expected_deprecations = [
945
920
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
946
921
'in version 1.4.']