~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-24 11:41:24 UTC
  • mfrom: (3449.1.2 unbreak-push-overwrite)
  • Revision ID: pqm@pqm.ubuntu.com-20080524114124-ubdyd5iqf7zxl2pn
Fix "bzr push --overwrite -r NNN". (Andrew Bennetts)

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
 
        medium.SmartClientMedium.__init__(self, base)
 
190
        self._remote_is_at_least_1_2 = True
191
191
        self._client_calls = client_calls
 
192
        self.base = base
192
193
 
193
194
    def disconnect(self):
194
195
        self._client_calls.append(('disconnect medium',))
253
254
                'xyz/', scheme + '//host/path', 'xyz/')
254
255
 
255
256
 
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.assertTrue(client_medium._is_remote_at_least((99, 99)))
265
 
    
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
270
 
        # still be 1.5.
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.
278
 
        self.assertRaises(
279
 
            AssertionError, client_medium._remote_is_not, (1, 9))
280
 
 
281
 
 
282
257
class TestBzrDirOpenBranch(tests.TestCase):
283
258
 
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/', ''))],
924
899
            client._calls)
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)
927
902
 
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.']