~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-15 08:20:33 UTC
  • mfrom: (4288.1.12 push.roundtrips)
  • Revision ID: pqm@pqm.ubuntu.com-20090415082033-tds4zs962x6kwc2c
(robertc) Add a Branch.set_parent_location verb and reduce lock
        churning to reduce network round trips. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
792
792
            response)
793
793
 
794
794
 
 
795
class TestSmartServerBranchRequestSetParent(tests.TestCaseWithMemoryTransport):
 
796
 
 
797
    def test_set_parent_none(self):
 
798
        branch = self.make_branch('base', format="1.9")
 
799
        branch.lock_write()
 
800
        branch._set_parent_location('foo')
 
801
        branch.unlock()
 
802
        request = smart.branch.SmartServerBranchRequestSetParentLocation(
 
803
            self.get_transport())
 
804
        branch_token = branch.lock_write()
 
805
        repo_token = branch.repository.lock_write()
 
806
        try:
 
807
            response = request.execute('base', branch_token, repo_token, '')
 
808
        finally:
 
809
            branch.repository.unlock()
 
810
            branch.unlock()
 
811
        self.assertEqual(SuccessfulSmartServerResponse(()), response)
 
812
        self.assertEqual(None, branch.get_parent())
 
813
 
 
814
    def test_set_parent_something(self):
 
815
        branch = self.make_branch('base', format="1.9")
 
816
        request = smart.branch.SmartServerBranchRequestSetParentLocation(
 
817
            self.get_transport())
 
818
        branch_token = branch.lock_write()
 
819
        repo_token = branch.repository.lock_write()
 
820
        try:
 
821
            response = request.execute('base', branch_token, repo_token,
 
822
            'http://bar/')
 
823
        finally:
 
824
            branch.repository.unlock()
 
825
            branch.unlock()
 
826
        self.assertEqual(SuccessfulSmartServerResponse(()), response)
 
827
        self.assertEqual('http://bar/', branch.get_parent())
 
828
 
 
829
 
795
830
class TestSmartServerBranchRequestGetTagsBytes(tests.TestCaseWithMemoryTransport):
796
831
# Only called when the branch format and tags match [yay factory
797
832
# methods] so only need to test straight forward cases.
1432
1467
            smart.branch.SmartServerBranchRequestSetLastRevision)
1433
1468
        self.assertHandlerEqual('Branch.set_last_revision_info',
1434
1469
            smart.branch.SmartServerBranchRequestSetLastRevisionInfo)
 
1470
        self.assertHandlerEqual('Branch.set_last_revision_ex',
 
1471
            smart.branch.SmartServerBranchRequestSetLastRevisionEx)
 
1472
        self.assertHandlerEqual('Branch.set_parent_location',
 
1473
            smart.branch.SmartServerBranchRequestSetParentLocation)
1435
1474
        self.assertHandlerEqual('Branch.unlock',
1436
1475
            smart.branch.SmartServerBranchRequestUnlock)
1437
1476
        self.assertHandlerEqual('BzrDir.find_repository',