/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Aaron Bentley
  • Date: 2005-10-18 19:47:04 UTC
  • mfrom: (1460)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1474.
  • Revision ID: abentley@panoramicfeedback.com-20051018194704-47d6827cc1d0d11b
Merged more config stuff from Robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.selftest import TestCaseInTempDir
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.commit import Commit
 
23
from bzrlib.config import BranchConfig
23
24
from bzrlib.errors import PointlessCommit, BzrError
24
25
 
25
26
 
26
27
# TODO: Test commit with some added, and added-but-missing files
27
28
 
 
29
class MustSignConfig(BranchConfig):
 
30
 
 
31
    def signature_needed(self):
 
32
        return True
 
33
 
 
34
    def gpg_signing_command(self):
 
35
        return ['cat', '-']
 
36
 
 
37
 
28
38
class TestCommit(TestCaseInTempDir):
29
39
 
30
40
    def test_simple_commit(self):
51
61
        tree2 = b.revision_tree(rh[1])
52
62
        eq(tree2.get_file_text(file_id), 'version 2')
53
63
 
54
 
 
55
64
    def test_delete_commit(self):
56
65
        """Test a commit with a deleted file"""
57
66
        b = Branch.initialize('.')
246
255
        self.assertEqual('1', inv['file1id'].revision)
247
256
        # FIXME: This should raise a KeyError I think, rbc20051006
248
257
        self.assertRaises(BzrError, inv.__getitem__, 'file2id')
 
258
 
 
259
    def test_signed_commit(self):
 
260
        import bzrlib.gpg
 
261
        import bzrlib.commit as commit
 
262
        oldstrategy = bzrlib.gpg.GPGStrategy
 
263
        branch = Branch.initialize('.')
 
264
        branch.commit("base", allow_pointless=True, rev_id='A')
 
265
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
266
        try:
 
267
            from bzrlib.testament import Testament
 
268
            # monkey patch gpg signing mechanism
 
269
            bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
 
270
            commit.Commit(config=MustSignConfig(branch)).commit(branch, "base",
 
271
                                                      allow_pointless=True,
 
272
                                                      rev_id='B')
 
273
            self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
 
274
                             branch.revision_store.get('B', 'sig').read())
 
275
        finally:
 
276
            bzrlib.gpg.GPGStrategy = oldstrategy