~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: Aaron Bentley
  • Date: 2006-11-10 01:55:55 UTC
  • mto: This revision was merged to the branch mainline in revision 2127.
  • Revision ID: aaron.bentley@utoronto.ca-20061110015555-f48202744b630209
Ignore html docs (both kinds)

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
24
from bzrlib.tests import TestCaseWithTransport
25
 
from bzrlib.testament import (
26
 
    Testament,
27
 
    StrictTestament,
28
 
    StrictTestament3,
29
 
    )
 
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
30
26
from bzrlib.transform import TreeTransform
31
 
from bzrlib.tests.features import (
32
 
    SymlinkFeature,
33
 
    )
 
27
from bzrlib.osutils import has_symlinks
34
28
 
35
29
 
36
30
class TestamentSetup(TestCaseWithTransport):
37
31
 
38
32
    def setUp(self):
39
33
        super(TestamentSetup, self).setUp()
40
 
        self.wt = self.make_branch_and_tree('.', format='development-subtree')
 
34
        self.wt = self.make_branch_and_tree('.')
41
35
        self.wt.set_root_id('TREE_ROT')
42
36
        b = self.b = self.wt.branch
43
37
        b.nick = "test branch"
104
98
 
105
99
    def test_testament_symlinks(self):
106
100
        """Testament containing symlink (where possible)"""
107
 
        self.requireFeature(SymlinkFeature)
 
101
        if not has_symlinks():
 
102
            return
108
103
        os.symlink('wibble/linktarget', 'link')
109
104
        self.wt.add(['link'], ['link-id'])
110
105
        self.wt.commit(message='add symlink',
136
131
            timestamp=1129025493,
137
132
            timezone=36000,
138
133
            rev_id='test@user-3',
139
 
            committer=u'Erik B\xe5gfors <test@user>',
 
134
            committer='Erik B\xe5gfors <test@user>',
140
135
            revprops={'uni':u'\xb5'}
141
136
            )
142
137
        t = self.from_revision(self.b.repository, 'test@user-3')
143
138
        self.assertEqualDiff(
144
139
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
145
140
 
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
141
    def test___init__(self):
155
142
        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)
 
143
        inventory = self.b.repository.get_inventory('test@user-2')
 
144
        testament_1 = self.testament_class()(revision, inventory)
158
145
        text_1 = testament_1.as_short_text()
159
 
        text_2 = self.from_revision(self.b.repository,
 
146
        text_2 = self.from_revision(self.b.repository, 
160
147
                                    'test@user-2').as_short_text()
161
148
        self.assertEqual(text_1, text_2)
162
 
 
 
149
                    
163
150
 
164
151
class TestamentTestsStrict(TestamentTests):
165
 
 
 
152
    
166
153
    def testament_class(self):
167
154
        return StrictTestament
168
155
 
169
156
 
170
157
class TestamentTestsStrict2(TestamentTests):
171
 
 
 
158
    
172
159
    def testament_class(self):
173
160
        return StrictTestament3
174
161
 
226
213
bazaar-ng testament short form 1
227
214
revision-id: test@user-1
228
215
sha1: %s
229
 
""" % osutils.sha_string(REV_1_TESTAMENT)
 
216
""" % sha(REV_1_TESTAMENT).hexdigest()
230
217
 
231
218
 
232
219
REV_1_SHORT_STRICT = """\
233
220
bazaar-ng testament short form 2.1
234
221
revision-id: test@user-1
235
222
sha1: %s
236
 
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT)
 
223
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
237
224
 
238
225
 
239
226
REV_1_SHORT_STRICT3 = """\
240
227
bazaar testament short form 3 strict
241
228
revision-id: test@user-1
242
229
sha1: %s
243
 
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT3)
 
230
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
244
231
 
245
232
 
246
233
REV_2_TESTAMENT = """\
294
281
message:
295
282
  add files and directories
296
283
inventory:
297
 
  directory . TREE_ROT test@user-1 no
 
284
  directory . TREE_ROT test@user-2 no
298
285
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
299
286
  directory src src-id test@user-2 no
300
287
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
308
295
bazaar-ng testament short form 1
309
296
revision-id: test@user-2
310
297
sha1: %s
311
 
""" % osutils.sha_string(REV_2_TESTAMENT)
 
298
""" % sha(REV_2_TESTAMENT).hexdigest()
312
299
 
313
300
 
314
301
REV_2_SHORT_STRICT = """\
315
302
bazaar-ng testament short form 2.1
316
303
revision-id: test@user-2
317
304
sha1: %s
318
 
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT)
 
305
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
319
306
 
320
307
 
321
308
REV_2_SHORT_STRICT3 = """\
322
309
bazaar testament short form 3 strict
323
310
revision-id: test@user-2
324
311
sha1: %s
325
 
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT3)
 
312
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
326
313
 
327
314
 
328
315
REV_PROPS_TESTAMENT = """\
388
375
message:
389
376
  revision with properties
390
377
inventory:
391
 
  directory . TREE_ROT test@user-1 no
 
378
  directory . TREE_ROT test@user-3 no
392
379
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
393
380
  directory src src-id test@user-2 no
394
381
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
457
444
message:
458
445
  add symlink
459
446
inventory:
460
 
  directory . TREE_ROT test@user-1 no
 
447
  directory . TREE_ROT test@user-3 no
461
448
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
462
449
  symlink link link-id wibble/linktarget test@user-3 no
463
450
  directory src src-id test@user-2 no
523
510
message:
524
511
  non-ascii commit \N{COPYRIGHT SIGN} me
525
512
inventory:
526
 
  directory . TREE_ROT test@user-1 no
 
513
  directory . TREE_ROT test@user-3 no
527
514
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
528
515
  directory src src-id test@user-2 no
529
516
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no