~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Patch Queue Manager
  • Date: 2011-11-25 16:02:51 UTC
  • mfrom: (6280.7.14 hpss-write-group)
  • Revision ID: pqm@pqm.ubuntu.com-20111125160251-zz514fqebn1gqgbi
(jelmer) Add HPSS calls for the write group methods. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1568
1568
            'Branch.unlock', ('branch/', 'branch token', 'repo token'),
1569
1569
            'success', ('ok',))
1570
1570
        branch = self.make_remote_branch(transport, client)
1571
 
        # This is a hack to work around the problem that RemoteBranch currently
1572
 
        # unnecessarily invokes _ensure_real upon a call to lock_write.
1573
 
        branch._ensure_real = lambda: None
1574
1571
        branch.lock_write()
1575
1572
        result = branch._set_last_revision(NULL_REVISION)
1576
1573
        branch.unlock()
1605
1602
            'Branch.unlock', ('branch/', 'branch token', 'repo token'),
1606
1603
            'success', ('ok',))
1607
1604
        branch = self.make_remote_branch(transport, client)
1608
 
        # This is a hack to work around the problem that RemoteBranch currently
1609
 
        # unnecessarily invokes _ensure_real upon a call to lock_write.
1610
 
        branch._ensure_real = lambda: None
1611
1605
        # Lock the branch, reset the record of remote calls.
1612
1606
        branch.lock_write()
1613
1607
        result = branch._set_last_revision('rev-id2')
1680
1674
            'Branch.unlock', ('branch/', 'branch token', 'repo token'),
1681
1675
            'success', ('ok',))
1682
1676
        branch = self.make_remote_branch(transport, client)
1683
 
        branch._ensure_real = lambda: None
1684
1677
        branch.lock_write()
1685
1678
        # The 'TipChangeRejected' error response triggered by calling
1686
1679
        # set_last_revision_info causes a TipChangeRejected exception.
2880
2873
            client._calls)
2881
2874
 
2882
2875
 
 
2876
class TestRepositoryWriteGroups(TestRemoteRepository):
 
2877
 
 
2878
    def test_start_write_group(self):
 
2879
        transport_path = 'quack'
 
2880
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2881
        client.add_expected_call(
 
2882
            'Repository.lock_write', ('quack/', ''),
 
2883
            'success', ('ok', 'a token'))
 
2884
        client.add_expected_call(
 
2885
            'Repository.start_write_group', ('quack/', 'a token'),
 
2886
            'success', ('ok', 'token1'))
 
2887
        repo.lock_write()
 
2888
        repo.start_write_group()
 
2889
 
 
2890
    def test_start_write_group_unsuspendable(self):
 
2891
        # Some repositories do not support suspending write
 
2892
        # groups. For those, fall back to the "real" repository.
 
2893
        transport_path = 'quack'
 
2894
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2895
        def stub_ensure_real():
 
2896
            client._calls.append(('_ensure_real',))
 
2897
            repo._real_repository = _StubRealPackRepository(client._calls)
 
2898
        repo._ensure_real = stub_ensure_real
 
2899
        client.add_expected_call(
 
2900
            'Repository.lock_write', ('quack/', ''),
 
2901
            'success', ('ok', 'a token'))
 
2902
        client.add_expected_call(
 
2903
            'Repository.start_write_group', ('quack/', 'a token'),
 
2904
            'error', ('UnsuspendableWriteGroup',))
 
2905
        repo.lock_write()
 
2906
        repo.start_write_group()
 
2907
        self.assertEquals(client._calls[-2:], [ 
 
2908
            ('_ensure_real',),
 
2909
            ('start_write_group',)])
 
2910
 
 
2911
    def test_commit_write_group(self):
 
2912
        transport_path = 'quack'
 
2913
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2914
        client.add_expected_call(
 
2915
            'Repository.lock_write', ('quack/', ''),
 
2916
            'success', ('ok', 'a token'))
 
2917
        client.add_expected_call(
 
2918
            'Repository.start_write_group', ('quack/', 'a token'),
 
2919
            'success', ('ok', ['token1']))
 
2920
        client.add_expected_call(
 
2921
            'Repository.commit_write_group', ('quack/', 'a token', ['token1']),
 
2922
            'success', ('ok',))
 
2923
        repo.lock_write()
 
2924
        repo.start_write_group()
 
2925
        repo.commit_write_group()
 
2926
 
 
2927
    def test_abort_write_group(self):
 
2928
        transport_path = 'quack'
 
2929
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2930
        client.add_expected_call(
 
2931
            'Repository.lock_write', ('quack/', ''),
 
2932
            'success', ('ok', 'a token'))
 
2933
        client.add_expected_call(
 
2934
            'Repository.start_write_group', ('quack/', 'a token'),
 
2935
            'success', ('ok', ['token1']))
 
2936
        client.add_expected_call(
 
2937
            'Repository.abort_write_group', ('quack/', 'a token', ['token1']),
 
2938
            'success', ('ok',))
 
2939
        repo.lock_write()
 
2940
        repo.start_write_group()
 
2941
        repo.abort_write_group(False)
 
2942
 
 
2943
    def test_suspend_write_group(self):
 
2944
        transport_path = 'quack'
 
2945
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2946
        self.assertEquals([], repo.suspend_write_group())
 
2947
 
 
2948
    def test_resume_write_group(self):
 
2949
        transport_path = 'quack'
 
2950
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
2951
        client.add_expected_call(
 
2952
            'Repository.lock_write', ('quack/', ''),
 
2953
            'success', ('ok', 'a token'))
 
2954
        client.add_expected_call(
 
2955
            'Repository.check_write_group', ('quack/', 'a token', ['token1']),
 
2956
            'success', ('ok',))
 
2957
        repo.lock_write()
 
2958
        repo.resume_write_group(['token1'])
 
2959
 
 
2960
 
2883
2961
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository):
2884
2962
 
2885
2963
    def test_backwards_compat(self):
3224
3302
        self.calls = calls
3225
3303
        self._pack_collection = _StubPackCollection(calls)
3226
3304
 
 
3305
    def start_write_group(self):
 
3306
        self.calls.append(('start_write_group',))
 
3307
 
3227
3308
    def is_in_write_group(self):
3228
3309
        return False
3229
3310