~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_sign_my_commits.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-15 09:21:49 UTC
  • mfrom: (6606.2.1 autodoc-unicode)
  • Revision ID: pqm@pqm.ubuntu.com-20160115092149-z5f4sfq3jvaz0enb
(vila) Fix autodoc runner when LANG=C. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Black-box tests for bzr sign-my-commits."""
19
19
 
20
 
import os
21
 
 
22
20
from bzrlib import (
23
21
    gpg,
24
22
    tests,
25
23
    )
26
 
from bzrlib.testament import Testament
27
 
from bzrlib.workingtree import WorkingTree
 
24
from bzrlib.tests.matchers import ContainsNoVfsCalls
28
25
 
29
26
 
30
27
class SignMyCommits(tests.TestCaseWithTransport):
45
42
        wt.commit("base C", allow_pointless=True, rev_id='C')
46
43
        wt.commit("base D", allow_pointless=True, rev_id='D',
47
44
                committer='Alternate <alt@foo.com>')
48
 
 
 
45
        wt.add_parent_tree_id("aghost")
 
46
        wt.commit("base E", allow_pointless=True, rev_id='E')
49
47
        return wt
50
48
 
51
49
    def assertUnsigned(self, repo, revision_id):
109
107
 
110
108
        out = self.run_bzr('sign-my-commits --dry-run')[0]
111
109
 
112
 
        self.assertEquals('A\nB\nC\nSigned 3 revisions\n', out)
 
110
        outlines = out.splitlines()
 
111
        self.assertEquals(5, len(outlines))
 
112
        self.assertEquals('Signed 4 revisions.', outlines[-1])
113
113
        self.assertUnsigned(repo, 'A')
114
114
        self.assertUnsigned(repo, 'B')
115
115
        self.assertUnsigned(repo, 'C')
116
116
        self.assertUnsigned(repo, 'D')
 
117
        self.assertUnsigned(repo, 'E')
 
118
 
 
119
 
 
120
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
 
121
 
 
122
    def monkey_patch_gpg(self):
 
123
        """Monkey patch the gpg signing strategy to be a loopback.
 
124
 
 
125
        This also registers the cleanup, so that we will revert to
 
126
        the original gpg strategy when done.
 
127
        """
 
128
        # monkey patch gpg signing mechanism
 
129
        self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
 
130
 
 
131
    def test_sign_single_commit(self):
 
132
        self.setup_smart_server_with_call_log()
 
133
        t = self.make_branch_and_tree('branch')
 
134
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
135
        t.add("foo")
 
136
        t.commit("message")
 
137
        self.reset_smart_call_log()
 
138
        self.monkey_patch_gpg()
 
139
        out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
 
140
        # This figure represent the amount of work to perform this use case. It
 
141
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
142
        # being too low. If rpc_count increases, more network roundtrips have
 
143
        # become necessary for this use case. Please do not adjust this number
 
144
        # upwards without agreement from bzr's network support maintainers.
 
145
        self.assertLength(15, self.hpss_calls)
 
146
        self.assertLength(1, self.hpss_connections)
 
147
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)