~bzr-pqm/bzr/bzr.dev

2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2005, 2006 Canonical Ltd
1185.16.12 by Martin Pool
- basic testament class
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.16.12 by Martin Pool
- basic testament class
16
17
"""Test testaments for gpg signing."""
18
1185.16.25 by Martin Pool
- testament symlink support
19
# TODO: Testaments with x-bits
1185.16.23 by Martin Pool
- clean up imports
20
1185.16.12 by Martin Pool
- basic testament class
21
import os
22
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
23
from bzrlib import osutils
2949.5.1 by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
1910.2.64 by Aaron Bentley
Changes from review
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
26
from bzrlib.transform import TreeTransform
1185.16.12 by Martin Pool
- basic testament class
27
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
28
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
29
class TestamentSetup(TestCaseWithTransport):
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
30
1185.16.15 by Martin Pool
- test text form for testaments
31
    def setUp(self):
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
32
        super(TestamentSetup, self).setUp()
2255.2.194 by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests.
33
        self.wt = self.make_branch_and_tree('.', format='dirstate-with-subtree')
1731.1.53 by Aaron Bentley
Fix testament text now that root are variable
34
        self.wt.set_root_id('TREE_ROT')
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
35
        b = self.b = self.wt.branch
1185.35.16 by Aaron Bentley
Fixed tests
36
        b.nick = "test branch"
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
37
        self.wt.commit(message='initial null commit',
1185.16.12 by Martin Pool
- basic testament class
38
                 committer='test@user',
39
                 timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
40
                 timezone=0,
41
                 rev_id='test@user-1')
1514 by Robert Collins
Unbreak self.build_tree_shape in tests.
42
        self.build_tree_contents([('hello', 'contents of hello file'),
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
43
                             ('src/', ),
1185.16.22 by Martin Pool
- more testament development
44
                             ('src/foo.c', 'int main()\n{\n}\n')])
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
45
        self.wt.add(['hello', 'src', 'src/foo.c'],
1508.1.5 by Robert Collins
Move add from Branch to WorkingTree.
46
                             ['hello-id', 'src-id', 'foo.c-id'])
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
47
        tt = TreeTransform(self.wt)
48
        trans_id = tt.trans_id_tree_path('hello')
49
        tt.set_executability(True, trans_id)
50
        tt.apply()
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
51
        self.wt.commit(message='add files and directories',
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
52
                 timestamp=1129025483,
53
                 timezone=36000,
54
                 rev_id='test@user-2',
55
                 committer='test@user')
1185.16.15 by Martin Pool
- test text form for testaments
56
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
57
58
class TestamentTests(TestamentSetup):
59
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
60
    def testament_class(self):
61
        return Testament
62
63
    def expected(self, key):
64
        return texts[self.testament_class()][key]
65
66
    def from_revision(self, repository, revision_id):
67
        return self.testament_class().from_revision(repository, revision_id)
68
1185.16.15 by Martin Pool
- test text form for testaments
69
    def test_null_testament(self):
70
        """Testament for a revision with no contents."""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
71
        t = self.from_revision(self.b.repository, 'test@user-1')
1185.16.12 by Martin Pool
- basic testament class
72
        ass = self.assertTrue
73
        eq = self.assertEqual
74
        ass(isinstance(t, Testament))
75
        eq(t.revision_id, 'test@user-1')
76
        eq(t.committer, 'test@user')
77
        eq(t.timestamp, 1129025423)
78
        eq(t.timezone, 0)
79
1185.16.15 by Martin Pool
- test text form for testaments
80
    def test_testment_text_form(self):
81
        """Conversion of testament to canonical text form."""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
82
        t = self.from_revision(self.b.repository, 'test@user-1')
83
        text_form = t.as_text()
84
        self.log('testament text form:\n' + text_form)
85
        self.assertEqualDiff(text_form, self.expected('rev_1'))
86
        short_text_form = t.as_short_text()
87
        self.assertEqualDiff(short_text_form, self.expected('rev_1_short'))
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
88
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
89
    def test_testament_with_contents(self):
90
        """Testament containing a file and a directory."""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
91
        t = self.from_revision(self.b.repository, 'test@user-2')
92
        text_form = t.as_text()
93
        self.log('testament text form:\n' + text_form)
94
        self.assertEqualDiff(text_form, self.expected('rev_2'))
95
        actual_short = t.as_short_text()
96
        self.assertEqualDiff(actual_short, self.expected('rev_2_short'))
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
97
1185.16.25 by Martin Pool
- testament symlink support
98
    def test_testament_symlinks(self):
99
        """Testament containing symlink (where possible)"""
2949.5.1 by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate
100
        self.requireFeature(SymlinkFeature)
1185.16.25 by Martin Pool
- testament symlink support
101
        os.symlink('wibble/linktarget', 'link')
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
102
        self.wt.add(['link'], ['link-id'])
103
        self.wt.commit(message='add symlink',
1185.16.25 by Martin Pool
- testament symlink support
104
                 timestamp=1129025493,
105
                 timezone=36000,
106
                 rev_id='test@user-3',
107
                 committer='test@user')
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
108
        t = self.from_revision(self.b.repository, 'test@user-3')
109
        self.assertEqualDiff(t.as_text(), self.expected('rev_3'))
1185.16.25 by Martin Pool
- testament symlink support
110
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
111
    def test_testament_revprops(self):
112
        """Testament to revision with extra properties"""
113
        props = dict(flavor='sour cherry\ncream cheese',
1886.1.5 by John Arbash Meinel
Assert that Testament can handle empty revprops as well
114
                     size='medium',
115
                     empty='',
116
                    )
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
117
        self.wt.commit(message='revision with properties',
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
118
                      timestamp=1129025493,
119
                      timezone=36000,
120
                      rev_id='test@user-3',
121
                      committer='test@user',
122
                      revprops=props)
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
123
        t = self.from_revision(self.b.repository, 'test@user-3')
124
        self.assertEqualDiff(t.as_text(), self.expected('rev_props'))
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
125
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
126
    def test_testament_unicode_commit_message(self):
1558.1.3 by Aaron Bentley
Fixed deprecated op use in test suite
127
        self.wt.commit(
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
128
            message=u'non-ascii commit \N{COPYRIGHT SIGN} me',
129
            timestamp=1129025493,
130
            timezone=36000,
131
            rev_id='test@user-3',
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
132
            committer='Erik B\xe5gfors <test@user>',
133
            revprops={'uni':u'\xb5'}
134
            )
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
135
        t = self.from_revision(self.b.repository, 'test@user-3')
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
136
        self.assertEqualDiff(
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
137
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
138
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
139
    def test___init__(self):
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
140
        revision = self.b.repository.get_revision('test@user-2')
141
        inventory = self.b.repository.get_inventory('test@user-2')
1910.2.62 by Aaron Bentley
Cleanups
142
        testament_1 = self.testament_class()(revision, inventory)
143
        text_1 = testament_1.as_short_text()
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
144
        text_2 = self.from_revision(self.b.repository,
1910.2.62 by Aaron Bentley
Cleanups
145
                                    'test@user-2').as_short_text()
146
        self.assertEqual(text_1, text_2)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
147
1185.16.25 by Martin Pool
- testament symlink support
148
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
149
class TestamentTestsStrict(TestamentTests):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
150
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
151
    def testament_class(self):
152
        return StrictTestament
153
154
155
class TestamentTestsStrict2(TestamentTests):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
156
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
157
    def testament_class(self):
1910.2.64 by Aaron Bentley
Changes from review
158
        return StrictTestament3
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
159
160
1185.16.25 by Martin Pool
- testament symlink support
161
REV_1_TESTAMENT = """\
162
bazaar-ng testament version 1
163
revision-id: test@user-1
164
committer: test@user
165
timestamp: 1129025423
166
timezone: 0
167
parents:
168
message:
169
  initial null commit
170
inventory:
1185.35.16 by Aaron Bentley
Fixed tests
171
properties:
172
  branch-nick:
173
    test branch
1185.16.25 by Martin Pool
- testament symlink support
174
"""
175
1910.2.62 by Aaron Bentley
Cleanups
176
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
177
REV_1_STRICT_TESTAMENT = """\
178
bazaar-ng testament version 2.1
179
revision-id: test@user-1
180
committer: test@user
181
timestamp: 1129025423
182
timezone: 0
183
parents:
184
message:
185
  initial null commit
186
inventory:
187
properties:
188
  branch-nick:
189
    test branch
190
"""
191
1910.2.62 by Aaron Bentley
Cleanups
192
1910.2.64 by Aaron Bentley
Changes from review
193
REV_1_STRICT_TESTAMENT3 = """\
194
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
195
revision-id: test@user-1
196
committer: test@user
197
timestamp: 1129025423
198
timezone: 0
199
parents:
200
message:
201
  initial null commit
202
inventory:
1731.1.53 by Aaron Bentley
Fix testament text now that root are variable
203
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
204
properties:
205
  branch-nick:
206
    test branch
207
"""
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
208
1910.2.62 by Aaron Bentley
Cleanups
209
1185.16.25 by Martin Pool
- testament symlink support
210
REV_1_SHORT = """\
211
bazaar-ng testament short form 1
212
revision-id: test@user-1
213
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
214
""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
1185.16.25 by Martin Pool
- testament symlink support
215
1185.16.24 by Martin Pool
- add and test 'testament' builtin command
216
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
217
REV_1_SHORT_STRICT = """\
218
bazaar-ng testament short form 2.1
219
revision-id: test@user-1
220
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
221
""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
222
223
1910.2.64 by Aaron Bentley
Changes from review
224
REV_1_SHORT_STRICT3 = """\
225
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
226
revision-id: test@user-1
227
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
228
""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
229
230
1185.16.24 by Martin Pool
- add and test 'testament' builtin command
231
REV_2_TESTAMENT = """\
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
232
bazaar-ng testament version 1
233
revision-id: test@user-2
234
committer: test@user
1185.16.22 by Martin Pool
- more testament development
235
timestamp: 1129025483
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
236
timezone: 36000
237
parents:
238
  test@user-1
239
message:
240
  add files and directories
241
inventory:
1185.16.22 by Martin Pool
- more testament development
242
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
243
  directory src src-id
244
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
245
properties:
246
  branch-nick:
247
    test branch
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
248
"""
1185.16.25 by Martin Pool
- testament symlink support
249
250
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
251
REV_2_STRICT_TESTAMENT = """\
252
bazaar-ng testament version 2.1
253
revision-id: test@user-2
254
committer: test@user
255
timestamp: 1129025483
256
timezone: 36000
257
parents:
258
  test@user-1
259
message:
260
  add files and directories
261
inventory:
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
262
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
263
  directory src src-id test@user-2 no
264
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
265
properties:
266
  branch-nick:
267
    test branch
268
"""
269
270
1910.2.64 by Aaron Bentley
Changes from review
271
REV_2_STRICT_TESTAMENT3 = """\
272
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
273
revision-id: test@user-2
274
committer: test@user
275
timestamp: 1129025483
276
timezone: 36000
277
parents:
278
  test@user-1
279
message:
280
  add files and directories
281
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
282
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
283
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
284
  directory src src-id test@user-2 no
285
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
286
properties:
287
  branch-nick:
288
    test branch
289
"""
290
1910.2.62 by Aaron Bentley
Cleanups
291
1185.16.25 by Martin Pool
- testament symlink support
292
REV_2_SHORT = """\
293
bazaar-ng testament short form 1
294
revision-id: test@user-2
295
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
296
""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
1185.16.25 by Martin Pool
- testament symlink support
297
298
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
299
REV_2_SHORT_STRICT = """\
300
bazaar-ng testament short form 2.1
301
revision-id: test@user-2
302
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
303
""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
304
305
1910.2.64 by Aaron Bentley
Changes from review
306
REV_2_SHORT_STRICT3 = """\
307
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
308
revision-id: test@user-2
309
sha1: %s
3734.2.4 by Vincent Ladeuil
Fix python2.6 deprecation warnings related to hashlib.
310
""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
311
312
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
313
REV_PROPS_TESTAMENT = """\
314
bazaar-ng testament version 1
315
revision-id: test@user-3
316
committer: test@user
317
timestamp: 1129025493
318
timezone: 36000
319
parents:
320
  test@user-2
321
message:
322
  revision with properties
323
inventory:
324
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
325
  directory src src-id
326
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
327
properties:
1185.35.16 by Aaron Bentley
Fixed tests
328
  branch-nick:
329
    test branch
1886.1.5 by John Arbash Meinel
Assert that Testament can handle empty revprops as well
330
  empty:
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
331
  flavor:
332
    sour cherry
333
    cream cheese
334
  size:
335
    medium
336
"""
337
338
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
339
REV_PROPS_TESTAMENT_STRICT = """\
340
bazaar-ng testament version 2.1
341
revision-id: test@user-3
342
committer: test@user
343
timestamp: 1129025493
344
timezone: 36000
345
parents:
346
  test@user-2
347
message:
348
  revision with properties
349
inventory:
350
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
351
  directory src src-id test@user-2 no
352
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
353
properties:
354
  branch-nick:
355
    test branch
356
  empty:
357
  flavor:
358
    sour cherry
359
    cream cheese
360
  size:
361
    medium
362
"""
363
364
1910.2.64 by Aaron Bentley
Changes from review
365
REV_PROPS_TESTAMENT_STRICT3 = """\
366
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
367
revision-id: test@user-3
368
committer: test@user
369
timestamp: 1129025493
370
timezone: 36000
371
parents:
372
  test@user-2
373
message:
374
  revision with properties
375
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
376
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
377
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
378
  directory src src-id test@user-2 no
379
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
380
properties:
381
  branch-nick:
382
    test branch
383
  empty:
384
  flavor:
385
    sour cherry
386
    cream cheese
387
  size:
388
    medium
389
"""
390
391
1185.16.25 by Martin Pool
- testament symlink support
392
REV_3_TESTAMENT = """\
393
bazaar-ng testament version 1
394
revision-id: test@user-3
395
committer: test@user
396
timestamp: 1129025493
397
timezone: 36000
398
parents:
399
  test@user-2
400
message:
401
  add symlink
402
inventory:
403
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
404
  symlink link link-id wibble/linktarget
405
  directory src src-id
406
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
407
properties:
408
  branch-nick:
409
    test branch
1185.16.25 by Martin Pool
- testament symlink support
410
"""
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
411
1553.3.3 by Marien Zwart
Whitespace cleanup (pep 3)
412
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
413
REV_3_TESTAMENT_STRICT = """\
414
bazaar-ng testament version 2.1
415
revision-id: test@user-3
416
committer: test@user
417
timestamp: 1129025493
418
timezone: 36000
419
parents:
420
  test@user-2
421
message:
422
  add symlink
423
inventory:
424
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
425
  symlink link link-id wibble/linktarget test@user-3 no
426
  directory src src-id test@user-2 no
427
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
428
properties:
429
  branch-nick:
430
    test branch
431
"""
432
433
1910.2.64 by Aaron Bentley
Changes from review
434
REV_3_TESTAMENT_STRICT3 = """\
435
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
436
revision-id: test@user-3
437
committer: test@user
438
timestamp: 1129025493
439
timezone: 36000
440
parents:
441
  test@user-2
442
message:
443
  add symlink
444
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
445
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
446
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
447
  symlink link link-id wibble/linktarget test@user-3 no
448
  directory src src-id test@user-2 no
449
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
450
properties:
451
  branch-nick:
452
    test branch
453
"""
454
1910.2.62 by Aaron Bentley
Cleanups
455
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
456
SAMPLE_UNICODE_TESTAMENT = u"""\
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
457
bazaar-ng testament version 1
458
revision-id: test@user-3
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
459
committer: Erik B\xe5gfors <test@user>
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
460
timestamp: 1129025493
461
timezone: 36000
462
parents:
463
  test@user-2
464
message:
465
  non-ascii commit \N{COPYRIGHT SIGN} me
466
inventory:
467
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
468
  directory src src-id
469
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
470
properties:
471
  branch-nick:
472
    test branch
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
473
  uni:
474
    \xb5
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
475
"""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
476
477
478
SAMPLE_UNICODE_TESTAMENT_STRICT = u"""\
479
bazaar-ng testament version 2.1
480
revision-id: test@user-3
481
committer: Erik B\xe5gfors <test@user>
482
timestamp: 1129025493
483
timezone: 36000
484
parents:
485
  test@user-2
486
message:
487
  non-ascii commit \N{COPYRIGHT SIGN} me
488
inventory:
489
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
490
  directory src src-id test@user-2 no
491
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
492
properties:
493
  branch-nick:
494
    test branch
495
  uni:
496
    \xb5
497
"""
498
499
1910.2.64 by Aaron Bentley
Changes from review
500
SAMPLE_UNICODE_TESTAMENT_STRICT3 = u"""\
501
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
502
revision-id: test@user-3
503
committer: Erik B\xe5gfors <test@user>
504
timestamp: 1129025493
505
timezone: 36000
506
parents:
507
  test@user-2
508
message:
509
  non-ascii commit \N{COPYRIGHT SIGN} me
510
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
511
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
512
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
513
  directory src src-id test@user-2 no
514
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
515
properties:
516
  branch-nick:
517
    test branch
518
  uni:
519
    \xb5
520
"""
521
522
523
texts = {
524
    Testament: { 'rev_1': REV_1_TESTAMENT,
525
                 'rev_1_short': REV_1_SHORT,
526
                 'rev_2': REV_2_TESTAMENT,
527
                 'rev_2_short': REV_2_SHORT,
528
                 'rev_3': REV_3_TESTAMENT,
529
                 'rev_props': REV_PROPS_TESTAMENT,
530
                 'sample_unicode': SAMPLE_UNICODE_TESTAMENT,
531
    },
532
    StrictTestament: {'rev_1': REV_1_STRICT_TESTAMENT,
533
                      'rev_1_short': REV_1_SHORT_STRICT,
534
                      'rev_2': REV_2_STRICT_TESTAMENT,
535
                      'rev_2_short': REV_2_SHORT_STRICT,
536
                      'rev_3': REV_3_TESTAMENT_STRICT,
537
                      'rev_props': REV_PROPS_TESTAMENT_STRICT,
538
                      'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT,
539
    },
1910.2.64 by Aaron Bentley
Changes from review
540
    StrictTestament3: {'rev_1': REV_1_STRICT_TESTAMENT3,
541
                      'rev_1_short': REV_1_SHORT_STRICT3,
542
                      'rev_2': REV_2_STRICT_TESTAMENT3,
543
                      'rev_2_short': REV_2_SHORT_STRICT3,
544
                      'rev_3': REV_3_TESTAMENT_STRICT3,
545
                      'rev_props': REV_PROPS_TESTAMENT_STRICT3,
546
                      'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT3,
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
547
    },
548
}