~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

- testament now contains summary of parents and inventory

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Test testaments for gpg signing."""
18
18
 
 
19
import difflib
19
20
import os
20
21
import sys
21
22
 
22
23
from bzrlib.selftest import TestCaseInTempDir
 
24
from bzrlib.selftest.treeshape import build_tree_contents
23
25
from bzrlib.branch import Branch
24
26
from bzrlib.testament import Testament
25
27
from bzrlib.trace import mutter
33
35
                 timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
34
36
                 timezone=0,
35
37
                 rev_id='test@user-1')
 
38
        build_tree_contents([('hello', 'contents of hello file'),
 
39
                             ('src/', ),
 
40
                             ('src/foo.c', 'int main()\n{\n}')])
 
41
        b.add(['hello', 'src', 'src/foo.c'])
 
42
        b.commit(message='add files and directories',
 
43
                 timestamp=1129025483,
 
44
                 timezone=36000,
 
45
                 rev_id='test@user-2',
 
46
                 committer='test@user')
36
47
 
37
48
    def test_null_testament(self):
38
49
        """Testament for a revision with no contents."""
57
68
timestamp: 1129025423.0
58
69
timezone: 0
59
70
entries: 0
 
71
parents:
60
72
message:
61
73
  initial null commit
 
74
inventory:
62
75
"""
63
76
        self.assertEqual(text_form, expect)
64
77
 
65
 
 
 
78
    def test_testament_with_contents(self):
 
79
        """Testament containing a file and a directory."""
 
80
        t = Testament.from_revision(self.b, 'test@user-2')
 
81
        text_form = t.to_text_form_1()
 
82
        self.log('testament text form:\n' + text_form)
 
83
        expect = """\
 
84
bazaar-ng testament version 1
 
85
revision-id: test@user-2
 
86
committer: test@user
 
87
timestamp: 1129025483.0
 
88
timezone: 36000
 
89
entries: 3
 
90
parents:
 
91
  test@user-1
 
92
message:
 
93
  add files and directories
 
94
inventory:
 
95
  file hello
 
96
  directory src
 
97
  file src/foo.c
 
98
"""
 
99
        self.assertEqualDiff(text_form, expect)