~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert J. Tanner
  • Date: 2009-04-29 05:53:21 UTC
  • mfrom: (4311 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4312.
  • Revision ID: tanner@real-time.com-20090429055321-v2s5l1mgki9f6cgn
[merge] 1.14 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
769
769
        return OldSmartClient()
770
770
 
771
771
 
772
 
class RemoteBranchTestCase(TestRemote):
 
772
class RemoteBzrDirTestCase(TestRemote):
 
773
 
 
774
    def make_remote_bzrdir(self, transport, client):
 
775
        """Make a RemotebzrDir using 'client' as the _client."""
 
776
        return RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
777
            _client=client)
 
778
 
 
779
 
 
780
class RemoteBranchTestCase(RemoteBzrDirTestCase):
773
781
 
774
782
    def make_remote_branch(self, transport, client):
775
783
        """Make a RemoteBranch using 'client' as its _SmartClient.
780
788
        # we do not want bzrdir to make any remote calls, so use False as its
781
789
        # _client.  If it tries to make a remote call, this will fail
782
790
        # immediately.
783
 
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
784
 
            _client=False)
 
791
        bzrdir = self.make_remote_bzrdir(transport, False)
785
792
        repo = RemoteRepository(bzrdir, None, _client=client)
786
793
        branch_format = self.get_branch_format()
787
794
        format = RemoteBranchFormat(network_name=branch_format.network_name())
836
843
        branch = self.make_remote_branch(transport, client)
837
844
        result = branch.get_parent()
838
845
        self.assertEqual('http://foo/', result)
 
846
        client.finished_test()
 
847
 
 
848
 
 
849
class TestBranchSetParentLocation(RemoteBranchTestCase):
 
850
 
 
851
    def test_no_parent(self):
 
852
        # We call the verb when setting parent to None
 
853
        transport = MemoryTransport()
 
854
        client = FakeClient(transport.base)
 
855
        client.add_expected_call(
 
856
            'Branch.get_stacked_on_url', ('quack/',),
 
857
            'error', ('NotStacked',))
 
858
        client.add_expected_call(
 
859
            'Branch.set_parent_location', ('quack/', 'b', 'r', ''),
 
860
            'success', ())
 
861
        transport.mkdir('quack')
 
862
        transport = transport.clone('quack')
 
863
        branch = self.make_remote_branch(transport, client)
 
864
        branch._lock_token = 'b'
 
865
        branch._repo_lock_token = 'r'
 
866
        branch._set_parent_location(None)
 
867
        client.finished_test()
 
868
 
 
869
    def test_parent(self):
 
870
        transport = MemoryTransport()
 
871
        client = FakeClient(transport.base)
 
872
        client.add_expected_call(
 
873
            'Branch.get_stacked_on_url', ('kwaak/',),
 
874
            'error', ('NotStacked',))
 
875
        client.add_expected_call(
 
876
            'Branch.set_parent_location', ('kwaak/', 'b', 'r', 'foo'),
 
877
            'success', ())
 
878
        transport.mkdir('kwaak')
 
879
        transport = transport.clone('kwaak')
 
880
        branch = self.make_remote_branch(transport, client)
 
881
        branch._lock_token = 'b'
 
882
        branch._repo_lock_token = 'r'
 
883
        branch._set_parent_location('foo')
 
884
        client.finished_test()
 
885
 
 
886
    def test_backwards_compat(self):
 
887
        self.setup_smart_server_with_call_log()
 
888
        branch = self.make_branch('.')
 
889
        self.reset_smart_call_log()
 
890
        verb = 'Branch.set_parent_location'
 
891
        self.disable_verb(verb)
 
892
        branch.set_parent('http://foo/')
 
893
        self.assertLength(12, self.hpss_calls)
839
894
 
840
895
 
841
896
class TestBranchGetTagsBytes(RemoteBranchTestCase):
1418
1473
        client.finished_test()
1419
1474
 
1420
1475
 
 
1476
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase):
 
1477
 
 
1478
    def test__get_config(self):
 
1479
        client = FakeClient()
 
1480
        client.add_success_response_with_body('default_stack_on = /\n', 'ok')
 
1481
        transport = MemoryTransport()
 
1482
        bzrdir = self.make_remote_bzrdir(transport, client)
 
1483
        config = bzrdir.get_config()
 
1484
        self.assertEqual('/', config.get_default_stack_on())
 
1485
        self.assertEqual(
 
1486
            [('call_expecting_body', 'BzrDir.get_config_file', ('memory:///',))],
 
1487
            client._calls)
 
1488
 
 
1489
    def test_set_option_uses_vfs(self):
 
1490
        self.setup_smart_server_with_call_log()
 
1491
        bzrdir = self.make_bzrdir('.')
 
1492
        self.reset_smart_call_log()
 
1493
        config = bzrdir.get_config()
 
1494
        config.set_default_stack_on('/')
 
1495
        self.assertLength(3, self.hpss_calls)
 
1496
 
 
1497
    def test_backwards_compat_get_option(self):
 
1498
        self.setup_smart_server_with_call_log()
 
1499
        bzrdir = self.make_bzrdir('.')
 
1500
        verb = 'BzrDir.get_config_file'
 
1501
        self.disable_verb(verb)
 
1502
        self.reset_smart_call_log()
 
1503
        self.assertEqual(None,
 
1504
            bzrdir._get_config().get_option('default_stack_on'))
 
1505
        self.assertLength(3, self.hpss_calls)
 
1506
 
 
1507
 
1421
1508
class TestTransportIsReadonly(tests.TestCase):
1422
1509
 
1423
1510
    def test_true(self):
2409
2496
        try:
2410
2497
            # it should have an appropriate fallback repository, which should also
2411
2498
            # be a RemoteRepository
2412
 
            self.assertEquals(len(remote_repo._fallback_repositories), 1)
 
2499
            self.assertLength(1, remote_repo._fallback_repositories)
2413
2500
            self.assertIsInstance(remote_repo._fallback_repositories[0],
2414
2501
                RemoteRepository)
2415
2502
            # and it has the revision committed to the underlying repository;