~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-02-24 05:37:17 UTC
  • mto: This revision was merged to the branch mainline in revision 4038.
  • Revision ID: robertc@robertcollins.net-20090224053717-sau62hnxgo2f1pzr
Create and use a RPC call to create branches on bzr servers rather than using VFS calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
            RemoteBzrDirFormat.probe_transport, OldServerTransport())
460
460
 
461
461
 
 
462
class TestBzrDirCreateBranch(TestRemote):
 
463
 
 
464
    def test_backwards_compat(self):
 
465
        self.setup_smart_server_with_call_log()
 
466
        repo = self.make_repository('.')
 
467
        self.reset_smart_call_log()
 
468
        self.disable_verb('BzrDir.create_branch')
 
469
        branch = repo.bzrdir.create_branch()
 
470
        create_branch_call_count = len([call for call in self.hpss_calls if
 
471
            call[0].method == 'BzrDir.create_branch'])
 
472
        self.assertEqual(1, create_branch_call_count)
 
473
 
 
474
    def test_current_server(self):
 
475
        transport = self.get_transport('.')
 
476
        transport = transport.clone('quack')
 
477
        self.make_repository('quack')
 
478
        client = FakeClient(transport.base)
 
479
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
480
        reference_format = reference_bzrdir_format.get_branch_format()
 
481
        network_name = reference_format.network_name()
 
482
        reference_repo_fmt = reference_bzrdir_format.repository_format
 
483
        reference_repo_name = reference_repo_fmt.network_name()
 
484
        client.add_expected_call(
 
485
            'BzrDir.create_branch', ('quack/', network_name),
 
486
            'success', ('ok', network_name, '', 'no', 'no', 'yes',
 
487
            reference_repo_name))
 
488
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
489
            _client=client)
 
490
        branch = a_bzrdir.create_branch()
 
491
        # We should have got a remote branch
 
492
        self.assertIsInstance(branch, remote.RemoteBranch)
 
493
        # its format should have the settings from the response
 
494
        format = branch._format
 
495
        self.assertEqual(network_name, format.network_name())
 
496
 
 
497
 
462
498
class TestBzrDirCreateRepository(TestRemote):
463
499
 
464
500
    def test_backwards_compat(self):
831
867
        branch = self.make_remote_branch(transport, client)
832
868
        branch._ensure_real = lambda: None
833
869
        branch.lock_write()
834
 
        self.addCleanup(branch.unlock)
835
870
        # The 'TipChangeRejected' error response triggered by calling
836
871
        # set_revision_history causes a TipChangeRejected exception.
837
872
        err = self.assertRaises(