~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 23:35:18 UTC
  • mfrom: (1442.1.65)
  • Revision ID: robertc@robertcollins.net-20051017233518-6746654be564edde
Merge in more GPG work, and more Branch-api-shrinkage.

* Branch.remove has been moved to WorkingTree, which has also gained
  lock_read, lock_write and unlock methods for convenience. (Robert
  Collins)

* Two decorators, needs_read_lock and needs_write_lock have been added
  to the branch module. Use these to cause a function to run in a
  read or write lock respectively. (Robert Collins)

* Branch.open_containing now returns a tuple (Branch, relative-path),
  which allows direct access to the common case of 'get me this file
  from its branch'. (Robert Collins)

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