~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: INADA Naoki
  • Date: 2011-05-05 13:03:12 UTC
  • mto: This revision was merged to the branch mainline in revision 5891.
  • Revision ID: songofacandy@gmail.com-20110505130312-ozvqmfjt7cuwi72k
Run build_mo when build is called.

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 TestCaseWithTransport
25
 
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
 
23
from bzrlib import osutils
 
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
 
25
from bzrlib.testament import (
 
26
    Testament,
 
27
    StrictTestament,
 
28
    StrictTestament3,
 
29
    )
26
30
from bzrlib.transform import TreeTransform
27
 
from bzrlib.osutils import has_symlinks
28
31
 
29
32
 
30
33
class TestamentSetup(TestCaseWithTransport):
98
101
 
99
102
    def test_testament_symlinks(self):
100
103
        """Testament containing symlink (where possible)"""
101
 
        if not has_symlinks():
102
 
            return
 
104
        self.requireFeature(SymlinkFeature)
103
105
        os.symlink('wibble/linktarget', 'link')
104
106
        self.wt.add(['link'], ['link-id'])
105
107
        self.wt.commit(message='add symlink',
131
133
            timestamp=1129025493,
132
134
            timezone=36000,
133
135
            rev_id='test@user-3',
134
 
            committer='Erik B\xe5gfors <test@user>',
 
136
            committer=u'Erik B\xe5gfors <test@user>',
135
137
            revprops={'uni':u'\xb5'}
136
138
            )
137
139
        t = self.from_revision(self.b.repository, 'test@user-3')
138
140
        self.assertEqualDiff(
139
141
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
140
142
 
 
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
 
141
151
    def test___init__(self):
142
152
        revision = self.b.repository.get_revision('test@user-2')
143
 
        inventory = self.b.repository.get_inventory('test@user-2')
144
 
        testament_1 = self.testament_class()(revision, inventory)
 
153
        tree = self.b.repository.revision_tree('test@user-2')
 
154
        testament_1 = self.testament_class()(revision, tree)
145
155
        text_1 = testament_1.as_short_text()
146
 
        text_2 = self.from_revision(self.b.repository, 
 
156
        text_2 = self.from_revision(self.b.repository,
147
157
                                    'test@user-2').as_short_text()
148
158
        self.assertEqual(text_1, text_2)
149
 
                    
 
159
 
150
160
 
151
161
class TestamentTestsStrict(TestamentTests):
152
 
    
 
162
 
153
163
    def testament_class(self):
154
164
        return StrictTestament
155
165
 
156
166
 
157
167
class TestamentTestsStrict2(TestamentTests):
158
 
    
 
168
 
159
169
    def testament_class(self):
160
170
        return StrictTestament3
161
171
 
213
223
bazaar-ng testament short form 1
214
224
revision-id: test@user-1
215
225
sha1: %s
216
 
""" % sha(REV_1_TESTAMENT).hexdigest()
 
226
""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
217
227
 
218
228
 
219
229
REV_1_SHORT_STRICT = """\
220
230
bazaar-ng testament short form 2.1
221
231
revision-id: test@user-1
222
232
sha1: %s
223
 
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
 
233
""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
224
234
 
225
235
 
226
236
REV_1_SHORT_STRICT3 = """\
227
237
bazaar testament short form 3 strict
228
238
revision-id: test@user-1
229
239
sha1: %s
230
 
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
 
240
""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
231
241
 
232
242
 
233
243
REV_2_TESTAMENT = """\
295
305
bazaar-ng testament short form 1
296
306
revision-id: test@user-2
297
307
sha1: %s
298
 
""" % sha(REV_2_TESTAMENT).hexdigest()
 
308
""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
299
309
 
300
310
 
301
311
REV_2_SHORT_STRICT = """\
302
312
bazaar-ng testament short form 2.1
303
313
revision-id: test@user-2
304
314
sha1: %s
305
 
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
 
315
""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
306
316
 
307
317
 
308
318
REV_2_SHORT_STRICT3 = """\
309
319
bazaar testament short form 3 strict
310
320
revision-id: test@user-2
311
321
sha1: %s
312
 
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
 
322
""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
313
323
 
314
324
 
315
325
REV_PROPS_TESTAMENT = """\