~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

  • Committer: Robert Collins
  • Date: 2005-10-17 21:57:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1462.
  • Revision ID: robertc@robertcollins.net-20051017215732-08f487800e726748
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.trace import mutter
30
30
from bzrlib.osutils import has_symlinks
31
31
 
 
32
 
32
33
class TestamentTests(TestCaseInTempDir):
 
34
 
33
35
    def setUp(self):
34
36
        super(TestamentTests, self).setUp()
35
37
        b = self.b = Branch.initialize('.')
102
104
        t = Testament.from_revision(self.b, 'test@user-3')
103
105
        self.assertEqualDiff(t.as_text(), REV_3_TESTAMENT)
104
106
 
 
107
    def test_testament_revprops(self):
 
108
        """Testament to revision with extra properties"""
 
109
        props = dict(flavor='sour cherry\ncream cheese',
 
110
                     size='medium')
 
111
        self.b.commit(message='revision with properties',
 
112
                      timestamp=1129025493,
 
113
                      timezone=36000,
 
114
                      rev_id='test@user-3',
 
115
                      committer='test@user',
 
116
                      revprops=props)
 
117
        t = Testament.from_revision(self.b, 'test@user-3')
 
118
        self.assertEqualDiff(t.as_text(), REV_PROPS_TESTAMENT)
 
119
 
 
120
    def test___init__(self):
 
121
        revision = self.b.get_revision('test@user-2')
 
122
        inventory = self.b.get_inventory('test@user-2')
 
123
        testament_1 = Testament(revision, inventory).as_short_text()
 
124
        testament_2 = Testament.from_revision(self.b, 
 
125
                                              'test@user-2').as_short_text()
 
126
        self.assertEqual(testament_1, testament_2)
 
127
                    
105
128
 
106
129
REV_1_TESTAMENT = """\
107
130
bazaar-ng testament version 1
146
169
""" % sha(REV_2_TESTAMENT).hexdigest()
147
170
 
148
171
 
 
172
REV_PROPS_TESTAMENT = """\
 
173
bazaar-ng testament version 1
 
174
revision-id: test@user-3
 
175
committer: test@user
 
176
timestamp: 1129025493
 
177
timezone: 36000
 
178
parents:
 
179
  test@user-2
 
180
message:
 
181
  revision with properties
 
182
inventory:
 
183
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
 
184
  directory src src-id
 
185
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
 
186
properties:
 
187
  flavor:
 
188
    sour cherry
 
189
    cream cheese
 
190
  size:
 
191
    medium
 
192
"""
 
193
 
 
194
 
149
195
REV_3_TESTAMENT = """\
150
196
bazaar-ng testament version 1
151
197
revision-id: test@user-3