~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

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
 
from bzrlib.tests import TestCaseWithTransport
25
 
from bzrlib.testament import (
26
 
    Testament,
27
 
    StrictTestament,
28
 
    StrictTestament3,
29
 
    )
 
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
 
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
30
26
from bzrlib.transform import TreeTransform
31
 
from bzrlib.tests.features import (
32
 
    SymlinkFeature,
33
 
    )
34
27
 
35
28
 
36
29
class TestamentSetup(TestCaseWithTransport):
37
30
 
38
31
    def setUp(self):
39
32
        super(TestamentSetup, self).setUp()
40
 
        self.wt = self.make_branch_and_tree('.', format='development-subtree')
 
33
        self.wt = self.make_branch_and_tree('.', format='dirstate-with-subtree')
41
34
        self.wt.set_root_id('TREE_ROT')
42
35
        b = self.b = self.wt.branch
43
36
        b.nick = "test branch"
136
129
            timestamp=1129025493,
137
130
            timezone=36000,
138
131
            rev_id='test@user-3',
139
 
            committer=u'Erik B\xe5gfors <test@user>',
 
132
            committer='Erik B\xe5gfors <test@user>',
140
133
            revprops={'uni':u'\xb5'}
141
134
            )
142
135
        t = self.from_revision(self.b.repository, 'test@user-3')
143
136
        self.assertEqualDiff(
144
137
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
145
138
 
146
 
    def test_from_tree(self):
147
 
        tree = self.b.repository.revision_tree('test@user-2')
148
 
        testament = self.testament_class().from_revision_tree(tree)
149
 
        text_1 = testament.as_short_text()
150
 
        text_2 = self.from_revision(self.b.repository,
151
 
                                    'test@user-2').as_short_text()
152
 
        self.assertEqual(text_1, text_2)
153
 
 
154
139
    def test___init__(self):
155
140
        revision = self.b.repository.get_revision('test@user-2')
156
 
        tree = self.b.repository.revision_tree('test@user-2')
157
 
        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)
158
143
        text_1 = testament_1.as_short_text()
159
 
        text_2 = self.from_revision(self.b.repository,
 
144
        text_2 = self.from_revision(self.b.repository, 
160
145
                                    'test@user-2').as_short_text()
161
146
        self.assertEqual(text_1, text_2)
162
 
 
 
147
                    
163
148
 
164
149
class TestamentTestsStrict(TestamentTests):
165
 
 
 
150
    
166
151
    def testament_class(self):
167
152
        return StrictTestament
168
153
 
169
154
 
170
155
class TestamentTestsStrict2(TestamentTests):
171
 
 
 
156
    
172
157
    def testament_class(self):
173
158
        return StrictTestament3
174
159
 
226
211
bazaar-ng testament short form 1
227
212
revision-id: test@user-1
228
213
sha1: %s
229
 
""" % osutils.sha_string(REV_1_TESTAMENT)
 
214
""" % sha(REV_1_TESTAMENT).hexdigest()
230
215
 
231
216
 
232
217
REV_1_SHORT_STRICT = """\
233
218
bazaar-ng testament short form 2.1
234
219
revision-id: test@user-1
235
220
sha1: %s
236
 
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT)
 
221
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
237
222
 
238
223
 
239
224
REV_1_SHORT_STRICT3 = """\
240
225
bazaar testament short form 3 strict
241
226
revision-id: test@user-1
242
227
sha1: %s
243
 
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT3)
 
228
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
244
229
 
245
230
 
246
231
REV_2_TESTAMENT = """\
308
293
bazaar-ng testament short form 1
309
294
revision-id: test@user-2
310
295
sha1: %s
311
 
""" % osutils.sha_string(REV_2_TESTAMENT)
 
296
""" % sha(REV_2_TESTAMENT).hexdigest()
312
297
 
313
298
 
314
299
REV_2_SHORT_STRICT = """\
315
300
bazaar-ng testament short form 2.1
316
301
revision-id: test@user-2
317
302
sha1: %s
318
 
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT)
 
303
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
319
304
 
320
305
 
321
306
REV_2_SHORT_STRICT3 = """\
322
307
bazaar testament short form 3 strict
323
308
revision-id: test@user-2
324
309
sha1: %s
325
 
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT3)
 
310
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
326
311
 
327
312
 
328
313
REV_PROPS_TESTAMENT = """\