~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Aaron Bentley
  • Date: 2005-10-18 20:19:44 UTC
  • mfrom: (1463) (0.2.1)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1474.
  • Revision ID: abentley@panoramicfeedback.com-20051018201944-42864e79d8e9ad29
Merged more from Robert

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
219
219
        b.add(['hello'], ['hello-id'])
220
220
        b.commit(message='add hello')
221
221
 
222
 
        b.remove('hello')
 
222
        b.working_tree().remove('hello')
223
223
        b.commit('removed hello', rev_id='rev2')
224
224
 
225
225
        tree = b.revision_tree('rev2')
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