~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

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