~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: Ian Clatworthy
  • Date: 2007-12-11 02:07:30 UTC
  • mto: (3119.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3120.
  • Revision ID: ian.clatworthy@internode.on.net-20071211020730-sdj4kj794dw0628e
make help topics more discoverable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Test testaments for gpg signing."""
18
18
 
19
19
# TODO: Testaments with x-bits
20
20
 
21
21
import os
 
22
from sha import sha
22
23
 
23
 
from bzrlib import osutils
24
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
25
 
from bzrlib.testament import (
26
 
    Testament,
27
 
    StrictTestament,
28
 
    StrictTestament3,
29
 
    )
 
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
30
26
from bzrlib.transform import TreeTransform
31
27
 
32
28
 
133
129
            timestamp=1129025493,
134
130
            timezone=36000,
135
131
            rev_id='test@user-3',
136
 
            committer=u'Erik B\xe5gfors <test@user>',
 
132
            committer='Erik B\xe5gfors <test@user>',
137
133
            revprops={'uni':u'\xb5'}
138
134
            )
139
135
        t = self.from_revision(self.b.repository, 'test@user-3')
140
136
        self.assertEqualDiff(
141
137
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
142
138
 
143
 
    def test_from_tree(self):
144
 
        tree = self.b.repository.revision_tree('test@user-2')
145
 
        testament = self.testament_class().from_revision_tree(tree)
146
 
        text_1 = testament.as_short_text()
147
 
        text_2 = self.from_revision(self.b.repository,
148
 
                                    'test@user-2').as_short_text()
149
 
        self.assertEqual(text_1, text_2)
150
 
 
151
139
    def test___init__(self):
152
140
        revision = self.b.repository.get_revision('test@user-2')
153
 
        tree = self.b.repository.revision_tree('test@user-2')
154
 
        testament_1 = self.testament_class()(revision, tree)
 
141
        inventory = self.b.repository.get_inventory('test@user-2')
 
142
        testament_1 = self.testament_class()(revision, inventory)
155
143
        text_1 = testament_1.as_short_text()
156
 
        text_2 = self.from_revision(self.b.repository,
 
144
        text_2 = self.from_revision(self.b.repository, 
157
145
                                    'test@user-2').as_short_text()
158
146
        self.assertEqual(text_1, text_2)
159
 
 
 
147
                    
160
148
 
161
149
class TestamentTestsStrict(TestamentTests):
162
 
 
 
150
    
163
151
    def testament_class(self):
164
152
        return StrictTestament
165
153
 
166
154
 
167
155
class TestamentTestsStrict2(TestamentTests):
168
 
 
 
156
    
169
157
    def testament_class(self):
170
158
        return StrictTestament3
171
159
 
223
211
bazaar-ng testament short form 1
224
212
revision-id: test@user-1
225
213
sha1: %s
226
 
""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
 
214
""" % sha(REV_1_TESTAMENT).hexdigest()
227
215
 
228
216
 
229
217
REV_1_SHORT_STRICT = """\
230
218
bazaar-ng testament short form 2.1
231
219
revision-id: test@user-1
232
220
sha1: %s
233
 
""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
 
221
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
234
222
 
235
223
 
236
224
REV_1_SHORT_STRICT3 = """\
237
225
bazaar testament short form 3 strict
238
226
revision-id: test@user-1
239
227
sha1: %s
240
 
""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
 
228
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
241
229
 
242
230
 
243
231
REV_2_TESTAMENT = """\
305
293
bazaar-ng testament short form 1
306
294
revision-id: test@user-2
307
295
sha1: %s
308
 
""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
 
296
""" % sha(REV_2_TESTAMENT).hexdigest()
309
297
 
310
298
 
311
299
REV_2_SHORT_STRICT = """\
312
300
bazaar-ng testament short form 2.1
313
301
revision-id: test@user-2
314
302
sha1: %s
315
 
""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
 
303
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
316
304
 
317
305
 
318
306
REV_2_SHORT_STRICT3 = """\
319
307
bazaar testament short form 3 strict
320
308
revision-id: test@user-2
321
309
sha1: %s
322
 
""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
 
310
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
323
311
 
324
312
 
325
313
REV_PROPS_TESTAMENT = """\