~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2009-04-14 02:35:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4291.
  • Revision ID: robertc@robertcollins.net-20090414023507-935t0u7ab2rt7kfk
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
770
770
        return OldSmartClient()
771
771
 
772
772
 
773
 
class RemoteBranchTestCase(TestRemote):
 
773
class RemoteBzrDirTestCase(TestRemote):
 
774
 
 
775
    def make_remote_bzrdir(self, transport, client):
 
776
        """Make a RemotebzrDir using 'client' as the _client."""
 
777
        return RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
778
            _client=client)
 
779
 
 
780
 
 
781
class RemoteBranchTestCase(RemoteBzrDirTestCase):
774
782
 
775
783
    def make_remote_branch(self, transport, client):
776
784
        """Make a RemoteBranch using 'client' as its _SmartClient.
781
789
        # we do not want bzrdir to make any remote calls, so use False as its
782
790
        # _client.  If it tries to make a remote call, this will fail
783
791
        # immediately.
784
 
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
785
 
            _client=False)
 
792
        bzrdir = self.make_remote_bzrdir(transport, False)
786
793
        repo = RemoteRepository(bzrdir, None, _client=client)
787
794
        branch_format = self.get_branch_format()
788
795
        format = RemoteBranchFormat(network_name=branch_format.network_name())
1419
1426
        client.finished_test()
1420
1427
 
1421
1428
 
 
1429
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase):
 
1430
 
 
1431
    def test__get_config(self):
 
1432
        client = FakeClient()
 
1433
        client.add_success_response_with_body('default_stack_on = /\n', 'ok')
 
1434
        transport = MemoryTransport()
 
1435
        bzrdir = self.make_remote_bzrdir(transport, client)
 
1436
        config = bzrdir.get_config()
 
1437
        self.assertEqual('/', config.get_default_stack_on())
 
1438
        self.assertEqual(
 
1439
            [('call_expecting_body', 'BzrDir.get_config_file', ('memory:///',))],
 
1440
            client._calls)
 
1441
 
 
1442
    def test_set_option_uses_vfs(self):
 
1443
        self.setup_smart_server_with_call_log()
 
1444
        bzrdir = self.make_bzrdir('.')
 
1445
        verb = 'BzrDir.get_config_file'
 
1446
        # self.disable_verb(verb)
 
1447
        self.reset_smart_call_log()
 
1448
        config = bzrdir.get_config()
 
1449
        config.set_default_stack_on('/')
 
1450
        self.assertLength(3, self.hpss_calls)
 
1451
 
 
1452
    def test_backwards_compat_get_option(self):
 
1453
        self.setup_smart_server_with_call_log()
 
1454
        bzrdir = self.make_bzrdir('.')
 
1455
        verb = 'BzrDir.get_config_file'
 
1456
        self.reset_smart_call_log()
 
1457
        self.assertEqual(None,
 
1458
            bzrdir._get_config().get_option('default_stack_on'))
 
1459
        self.assertLength(3, self.hpss_calls)
 
1460
 
 
1461
 
1422
1462
class TestTransportIsReadonly(tests.TestCase):
1423
1463
 
1424
1464
    def test_true(self):