~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Robert Collins
  • Date: 2005-10-17 21:57:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1462.
  • Revision ID: robertc@robertcollins.net-20051017215732-08f487800e726748
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.commit import Commit
23
23
from bzrlib.config import BranchConfig
24
 
from bzrlib.errors import PointlessCommit, BzrError
 
24
from bzrlib.errors import PointlessCommit, BzrError, SigningFailed
25
25
 
26
26
 
27
27
# TODO: Test commit with some added, and added-but-missing files
274
274
                             branch.revision_store.get('B', 'sig').read())
275
275
        finally:
276
276
            bzrlib.gpg.GPGStrategy = oldstrategy
 
277
 
 
278
    def test_commit_failed_signature(self):
 
279
        import bzrlib.gpg
 
280
        import bzrlib.commit as commit
 
281
        oldstrategy = bzrlib.gpg.GPGStrategy
 
282
        branch = Branch.initialize('.')
 
283
        branch.commit("base", allow_pointless=True, rev_id='A')
 
284
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
285
        try:
 
286
            from bzrlib.testament import Testament
 
287
            # monkey patch gpg signing mechanism
 
288
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.DisabledGPGStrategy
 
289
            config = MustSignConfig(branch)
 
290
            self.assertRaises(SigningFailed,
 
291
                              commit.Commit(config=config).commit,
 
292
                              branch, "base",
 
293
                              allow_pointless=True,
 
294
                              rev_id='B')
 
295
            branch = Branch.open('.')
 
296
            self.assertEqual(branch.revision_history(), ['A'])
 
297
            self.failIf(branch.revision_store.has_id('B'))
 
298
        finally:
 
299
            bzrlib.gpg.GPGStrategy = oldstrategy
 
300
 
 
301