~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

- test text form for testaments

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.selftest import TestCaseInTempDir
23
23
from bzrlib.branch import Branch
24
24
from bzrlib.testament import Testament
 
25
from bzrlib.trace import mutter
25
26
 
26
27
class TestamentTests(TestCaseInTempDir):
27
 
 
28
 
    def test_null_testament(self):
29
 
        """Testament for a revision with no contents."""
30
 
        b = Branch.initialize('.')
 
28
    def setUp(self):
 
29
        super(TestamentTests, self).setUp()
 
30
        b = self.b = Branch.initialize('.')
31
31
        b.commit(message='initial null commit',
32
32
                 committer='test@user',
33
33
                 timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
34
34
                 timezone=0,
35
35
                 rev_id='test@user-1')
36
 
        t = Testament.from_revision(b, 'test@user-1')
 
36
 
 
37
    def test_null_testament(self):
 
38
        """Testament for a revision with no contents."""
 
39
        t = Testament.from_revision(self.b, 'test@user-1')
37
40
        ass = self.assertTrue
38
41
        eq = self.assertEqual
39
42
        ass(isinstance(t, Testament))
42
45
        eq(t.timestamp, 1129025423)
43
46
        eq(t.timezone, 0)
44
47
 
 
48
    def test_testment_text_form(self):
 
49
        """Conversion of testament to canonical text form."""
 
50
        t = Testament.from_revision(self.b, 'test@user-1')
 
51
        text_form = t.to_text_form_1()
 
52
        self.log('testament text form:\n' + text_form)
 
53
        expect = """\
 
54
bazaar-ng testament version 1
 
55
revision-id: test@user-1
 
56
committer: test@user
 
57
timestamp: 1129025423.0
 
58
timezone: 0
 
59
entries: 0
 
60
message:
 
61
  initial null commit
 
62
"""
 
63
        self.assertEqual(text_form, expect)
 
64
 
 
65