~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-08-13 14:16:53 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070813141653-3cbrp00xowq58zv1
Added mini tutorial

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