1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005-2010 Canonical Ltd
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
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
17
17
"""Test testaments for gpg signing."""
19
19
# TODO: Testaments with x-bits
23
from bzrlib import osutils
24
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
25
from bzrlib.testament import (
26
30
from bzrlib.transform import TreeTransform
129
133
timestamp=1129025493,
131
135
rev_id='test@user-3',
132
committer='Erik B\xe5gfors <test@user>',
136
committer=u'Erik B\xe5gfors <test@user>',
133
137
revprops={'uni':u'\xb5'}
135
139
t = self.from_revision(self.b.repository, 'test@user-3')
136
140
self.assertEqualDiff(
137
141
self.expected('sample_unicode').encode('utf-8'), t.as_text())
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)
139
151
def test___init__(self):
140
152
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)
153
tree = self.b.repository.revision_tree('test@user-2')
154
testament_1 = self.testament_class()(revision, tree)
143
155
text_1 = testament_1.as_short_text()
144
text_2 = self.from_revision(self.b.repository,
156
text_2 = self.from_revision(self.b.repository,
145
157
'test@user-2').as_short_text()
146
158
self.assertEqual(text_1, text_2)
149
161
class TestamentTestsStrict(TestamentTests):
151
163
def testament_class(self):
152
164
return StrictTestament
155
167
class TestamentTestsStrict2(TestamentTests):
157
169
def testament_class(self):
158
170
return StrictTestament3
211
223
bazaar-ng testament short form 1
212
224
revision-id: test@user-1
214
""" % sha(REV_1_TESTAMENT).hexdigest()
226
""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
217
229
REV_1_SHORT_STRICT = """\
218
230
bazaar-ng testament short form 2.1
219
231
revision-id: test@user-1
221
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
233
""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
224
236
REV_1_SHORT_STRICT3 = """\
225
237
bazaar testament short form 3 strict
226
238
revision-id: test@user-1
228
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
240
""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
231
243
REV_2_TESTAMENT = """\
293
305
bazaar-ng testament short form 1
294
306
revision-id: test@user-2
296
""" % sha(REV_2_TESTAMENT).hexdigest()
308
""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
299
311
REV_2_SHORT_STRICT = """\
300
312
bazaar-ng testament short form 2.1
301
313
revision-id: test@user-2
303
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
315
""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
306
318
REV_2_SHORT_STRICT3 = """\
307
319
bazaar testament short form 3 strict
308
320
revision-id: test@user-2
310
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
322
""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
313
325
REV_PROPS_TESTAMENT = """\