~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Martin Pool
  • Date: 2008-06-25 10:06:48 UTC
  • mfrom: (3509 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3510.
  • Revision ID: mbp@sourcefrog.net-20080625100648-ac20jxcm3ojucuby
merge trunk; remove RemoteToOtherFetcher

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
class FakeMedium(medium.SmartClientMedium):
188
188
 
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
192
 
        self.base = base
193
192
 
194
193
    def disconnect(self):
195
194
        self._client_calls.append(('disconnect medium',))
254
253
                'xyz/', scheme + '//host/path', 'xyz/')
255
254
 
256
255
 
 
256
class Test_ClientMedium_remote_is_at_least(tests.TestCase):
 
257
    """Tests for the behaviour of client_medium.remote_is_at_least."""
 
258
 
 
259
    def test_initially_unlimited(self):
 
260
        """A fresh medium assumes that the remote side supports all
 
261
        versions.
 
262
        """
 
263
        client_medium = medium.SmartClientMedium('dummy base')
 
264
        self.assertFalse(client_medium._is_remote_before((99, 99)))
 
265
    
 
266
    def test__remember_remote_is_before(self):
 
267
        """Calling _remember_remote_is_before ratchets down the known remote
 
268
        version.
 
269
        """
 
270
        client_medium = medium.SmartClientMedium('dummy base')
 
271
        # Mark the remote side as being less than 1.6.  The remote side may
 
272
        # still be 1.5.
 
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.
 
280
        self.assertRaises(
 
281
            AssertionError, client_medium._remember_remote_is_before, (1, 9))
 
282
 
 
283
 
257
284
class TestBzrDirOpenBranch(tests.TestCase):
258
285
 
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/', ''))],
899
926
            client._calls)
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)))
902
929
 
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.']