/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1910.2.64 by Aaron Bentley
Changes from review
1
# Copyright (C) 2005-2006 by 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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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
1185.16.22 by Martin Pool
- more testament development
22
from sha import sha
1185.16.12 by Martin Pool
- basic testament class
23
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
24
from bzrlib.tests import 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.25 by Martin Pool
- testament symlink support
27
from bzrlib.osutils import has_symlinks
1185.16.12 by Martin Pool
- basic testament class
28
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
29
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
30
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.
31
1185.16.15 by Martin Pool
- test text form for testaments
32
    def setUp(self):
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
33
        super(TestamentSetup, self).setUp()
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
34
        self.wt = self.make_branch_and_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)"""
100
        if not has_symlinks():
101
            return
102
        os.symlink('wibble/linktarget', 'link')
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
103
        self.wt.add(['link'], ['link-id'])
104
        self.wt.commit(message='add symlink',
1185.16.25 by Martin Pool
- testament symlink support
105
                 timestamp=1129025493,
106
                 timezone=36000,
107
                 rev_id='test@user-3',
108
                 committer='test@user')
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
109
        t = self.from_revision(self.b.repository, 'test@user-3')
110
        self.assertEqualDiff(t.as_text(), self.expected('rev_3'))
1185.16.25 by Martin Pool
- testament symlink support
111
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
112
    def test_testament_revprops(self):
113
        """Testament to revision with extra properties"""
114
        props = dict(flavor='sour cherry\ncream cheese',
1886.1.5 by John Arbash Meinel
Assert that Testament can handle empty revprops as well
115
                     size='medium',
116
                     empty='',
117
                    )
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
118
        self.wt.commit(message='revision with properties',
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
119
                      timestamp=1129025493,
120
                      timezone=36000,
121
                      rev_id='test@user-3',
122
                      committer='test@user',
123
                      revprops=props)
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
124
        t = self.from_revision(self.b.repository, 'test@user-3')
125
        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.
126
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
127
    def test_testament_unicode_commit_message(self):
1558.1.3 by Aaron Bentley
Fixed deprecated op use in test suite
128
        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.
129
            message=u'non-ascii commit \N{COPYRIGHT SIGN} me',
130
            timestamp=1129025493,
131
            timezone=36000,
132
            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)
133
            committer='Erik B\xe5gfors <test@user>',
134
            revprops={'uni':u'\xb5'}
135
            )
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
136
        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.
137
        self.assertEqualDiff(
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
138
            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.
139
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
140
    def test___init__(self):
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
141
        revision = self.b.repository.get_revision('test@user-2')
142
        inventory = self.b.repository.get_inventory('test@user-2')
1910.2.62 by Aaron Bentley
Cleanups
143
        testament_1 = self.testament_class()(revision, inventory)
144
        text_1 = testament_1.as_short_text()
145
        text_2 = self.from_revision(self.b.repository, 
146
                                    'test@user-2').as_short_text()
147
        self.assertEqual(text_1, text_2)
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
148
                    
1185.16.25 by Martin Pool
- testament symlink support
149
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
150
class TestamentTestsStrict(TestamentTests):
151
    
152
    def testament_class(self):
153
        return StrictTestament
154
155
156
class TestamentTestsStrict2(TestamentTests):
157
    
158
    def testament_class(self):
1910.2.64 by Aaron Bentley
Changes from review
159
        return StrictTestament3
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
160
161
1185.16.25 by Martin Pool
- testament symlink support
162
REV_1_TESTAMENT = """\
163
bazaar-ng testament version 1
164
revision-id: test@user-1
165
committer: test@user
166
timestamp: 1129025423
167
timezone: 0
168
parents:
169
message:
170
  initial null commit
171
inventory:
1185.35.16 by Aaron Bentley
Fixed tests
172
properties:
173
  branch-nick:
174
    test branch
1185.16.25 by Martin Pool
- testament symlink support
175
"""
176
1910.2.62 by Aaron Bentley
Cleanups
177
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
178
REV_1_STRICT_TESTAMENT = """\
179
bazaar-ng testament version 2.1
180
revision-id: test@user-1
181
committer: test@user
182
timestamp: 1129025423
183
timezone: 0
184
parents:
185
message:
186
  initial null commit
187
inventory:
188
properties:
189
  branch-nick:
190
    test branch
191
"""
192
1910.2.62 by Aaron Bentley
Cleanups
193
1910.2.64 by Aaron Bentley
Changes from review
194
REV_1_STRICT_TESTAMENT3 = """\
195
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
196
revision-id: test@user-1
197
committer: test@user
198
timestamp: 1129025423
199
timezone: 0
200
parents:
201
message:
202
  initial null commit
203
inventory:
204
  directory . TREE_ROOT test@user-1 no
205
properties:
206
  branch-nick:
207
    test branch
208
"""
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
209
1910.2.62 by Aaron Bentley
Cleanups
210
1185.16.25 by Martin Pool
- testament symlink support
211
REV_1_SHORT = """\
212
bazaar-ng testament short form 1
213
revision-id: test@user-1
214
sha1: %s
215
""" % sha(REV_1_TESTAMENT).hexdigest()
216
1185.16.24 by Martin Pool
- add and test 'testament' builtin command
217
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
218
REV_1_SHORT_STRICT = """\
219
bazaar-ng testament short form 2.1
220
revision-id: test@user-1
221
sha1: %s
222
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
223
224
1910.2.64 by Aaron Bentley
Changes from review
225
REV_1_SHORT_STRICT3 = """\
226
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
227
revision-id: test@user-1
228
sha1: %s
1910.2.64 by Aaron Bentley
Changes from review
229
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
230
231
1185.16.24 by Martin Pool
- add and test 'testament' builtin command
232
REV_2_TESTAMENT = """\
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
233
bazaar-ng testament version 1
234
revision-id: test@user-2
235
committer: test@user
1185.16.22 by Martin Pool
- more testament development
236
timestamp: 1129025483
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
237
timezone: 36000
238
parents:
239
  test@user-1
240
message:
241
  add files and directories
242
inventory:
1185.16.22 by Martin Pool
- more testament development
243
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
244
  directory src src-id
245
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
246
properties:
247
  branch-nick:
248
    test branch
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
249
"""
1185.16.25 by Martin Pool
- testament symlink support
250
251
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
252
REV_2_STRICT_TESTAMENT = """\
253
bazaar-ng testament version 2.1
254
revision-id: test@user-2
255
committer: test@user
256
timestamp: 1129025483
257
timezone: 36000
258
parents:
259
  test@user-1
260
message:
261
  add files and directories
262
inventory:
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
263
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
264
  directory src src-id test@user-2 no
265
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
266
properties:
267
  branch-nick:
268
    test branch
269
"""
270
271
1910.2.64 by Aaron Bentley
Changes from review
272
REV_2_STRICT_TESTAMENT3 = """\
273
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
274
revision-id: test@user-2
275
committer: test@user
276
timestamp: 1129025483
277
timezone: 36000
278
parents:
279
  test@user-1
280
message:
281
  add files and directories
282
inventory:
283
  directory . TREE_ROOT test@user-2 no
284
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
285
  directory src src-id test@user-2 no
286
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
287
properties:
288
  branch-nick:
289
    test branch
290
"""
291
1910.2.62 by Aaron Bentley
Cleanups
292
1185.16.25 by Martin Pool
- testament symlink support
293
REV_2_SHORT = """\
294
bazaar-ng testament short form 1
295
revision-id: test@user-2
296
sha1: %s
297
""" % sha(REV_2_TESTAMENT).hexdigest()
298
299
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
300
REV_2_SHORT_STRICT = """\
301
bazaar-ng testament short form 2.1
302
revision-id: test@user-2
303
sha1: %s
304
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
305
306
1910.2.64 by Aaron Bentley
Changes from review
307
REV_2_SHORT_STRICT3 = """\
308
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
309
revision-id: test@user-2
310
sha1: %s
1910.2.64 by Aaron Bentley
Changes from review
311
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
312
313
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
314
REV_PROPS_TESTAMENT = """\
315
bazaar-ng testament version 1
316
revision-id: test@user-3
317
committer: test@user
318
timestamp: 1129025493
319
timezone: 36000
320
parents:
321
  test@user-2
322
message:
323
  revision with properties
324
inventory:
325
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
326
  directory src src-id
327
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
328
properties:
1185.35.16 by Aaron Bentley
Fixed tests
329
  branch-nick:
330
    test branch
1886.1.5 by John Arbash Meinel
Assert that Testament can handle empty revprops as well
331
  empty:
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
332
  flavor:
333
    sour cherry
334
    cream cheese
335
  size:
336
    medium
337
"""
338
339
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
340
REV_PROPS_TESTAMENT_STRICT = """\
341
bazaar-ng testament version 2.1
342
revision-id: test@user-3
343
committer: test@user
344
timestamp: 1129025493
345
timezone: 36000
346
parents:
347
  test@user-2
348
message:
349
  revision with properties
350
inventory:
351
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
352
  directory src src-id test@user-2 no
353
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
354
properties:
355
  branch-nick:
356
    test branch
357
  empty:
358
  flavor:
359
    sour cherry
360
    cream cheese
361
  size:
362
    medium
363
"""
364
365
1910.2.64 by Aaron Bentley
Changes from review
366
REV_PROPS_TESTAMENT_STRICT3 = """\
367
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
368
revision-id: test@user-3
369
committer: test@user
370
timestamp: 1129025493
371
timezone: 36000
372
parents:
373
  test@user-2
374
message:
375
  revision with properties
376
inventory:
377
  directory . TREE_ROOT test@user-3 no
378
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
379
  directory src src-id test@user-2 no
380
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
381
properties:
382
  branch-nick:
383
    test branch
384
  empty:
385
  flavor:
386
    sour cherry
387
    cream cheese
388
  size:
389
    medium
390
"""
391
392
1185.16.25 by Martin Pool
- testament symlink support
393
REV_3_TESTAMENT = """\
394
bazaar-ng testament version 1
395
revision-id: test@user-3
396
committer: test@user
397
timestamp: 1129025493
398
timezone: 36000
399
parents:
400
  test@user-2
401
message:
402
  add symlink
403
inventory:
404
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
405
  symlink link link-id wibble/linktarget
406
  directory src src-id
407
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
408
properties:
409
  branch-nick:
410
    test branch
1185.16.25 by Martin Pool
- testament symlink support
411
"""
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
412
1553.3.3 by Marien Zwart
Whitespace cleanup (pep 3)
413
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
414
REV_3_TESTAMENT_STRICT = """\
415
bazaar-ng testament version 2.1
416
revision-id: test@user-3
417
committer: test@user
418
timestamp: 1129025493
419
timezone: 36000
420
parents:
421
  test@user-2
422
message:
423
  add symlink
424
inventory:
425
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
426
  symlink link link-id wibble/linktarget test@user-3 no
427
  directory src src-id test@user-2 no
428
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
429
properties:
430
  branch-nick:
431
    test branch
432
"""
433
434
1910.2.64 by Aaron Bentley
Changes from review
435
REV_3_TESTAMENT_STRICT3 = """\
436
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
437
revision-id: test@user-3
438
committer: test@user
439
timestamp: 1129025493
440
timezone: 36000
441
parents:
442
  test@user-2
443
message:
444
  add symlink
445
inventory:
446
  directory . TREE_ROOT test@user-3 no
447
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
448
  symlink link link-id wibble/linktarget test@user-3 no
449
  directory src src-id test@user-2 no
450
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
451
properties:
452
  branch-nick:
453
    test branch
454
"""
455
1910.2.62 by Aaron Bentley
Cleanups
456
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
457
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.
458
bazaar-ng testament version 1
459
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)
460
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.
461
timestamp: 1129025493
462
timezone: 36000
463
parents:
464
  test@user-2
465
message:
466
  non-ascii commit \N{COPYRIGHT SIGN} me
467
inventory:
468
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
469
  directory src src-id
470
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
471
properties:
472
  branch-nick:
473
    test branch
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
474
  uni:
475
    \xb5
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
476
"""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
477
478
479
SAMPLE_UNICODE_TESTAMENT_STRICT = u"""\
480
bazaar-ng testament version 2.1
481
revision-id: test@user-3
482
committer: Erik B\xe5gfors <test@user>
483
timestamp: 1129025493
484
timezone: 36000
485
parents:
486
  test@user-2
487
message:
488
  non-ascii commit \N{COPYRIGHT SIGN} me
489
inventory:
490
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
491
  directory src src-id test@user-2 no
492
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
493
properties:
494
  branch-nick:
495
    test branch
496
  uni:
497
    \xb5
498
"""
499
500
1910.2.64 by Aaron Bentley
Changes from review
501
SAMPLE_UNICODE_TESTAMENT_STRICT3 = u"""\
502
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
503
revision-id: test@user-3
504
committer: Erik B\xe5gfors <test@user>
505
timestamp: 1129025493
506
timezone: 36000
507
parents:
508
  test@user-2
509
message:
510
  non-ascii commit \N{COPYRIGHT SIGN} me
511
inventory:
512
  directory . TREE_ROOT test@user-3 no
513
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
514
  directory src src-id test@user-2 no
515
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
516
properties:
517
  branch-nick:
518
    test branch
519
  uni:
520
    \xb5
521
"""
522
523
524
texts = {
525
    Testament: { 'rev_1': REV_1_TESTAMENT,
526
                 'rev_1_short': REV_1_SHORT,
527
                 'rev_2': REV_2_TESTAMENT,
528
                 'rev_2_short': REV_2_SHORT,
529
                 'rev_3': REV_3_TESTAMENT,
530
                 'rev_props': REV_PROPS_TESTAMENT,
531
                 'sample_unicode': SAMPLE_UNICODE_TESTAMENT,
532
    },
533
    StrictTestament: {'rev_1': REV_1_STRICT_TESTAMENT,
534
                      'rev_1_short': REV_1_SHORT_STRICT,
535
                      'rev_2': REV_2_STRICT_TESTAMENT,
536
                      'rev_2_short': REV_2_SHORT_STRICT,
537
                      'rev_3': REV_3_TESTAMENT_STRICT,
538
                      'rev_props': REV_PROPS_TESTAMENT_STRICT,
539
                      'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT,
540
    },
1910.2.64 by Aaron Bentley
Changes from review
541
    StrictTestament3: {'rev_1': REV_1_STRICT_TESTAMENT3,
542
                      'rev_1_short': REV_1_SHORT_STRICT3,
543
                      'rev_2': REV_2_STRICT_TESTAMENT3,
544
                      'rev_2_short': REV_2_SHORT_STRICT3,
545
                      'rev_3': REV_3_TESTAMENT_STRICT3,
546
                      'rev_props': REV_PROPS_TESTAMENT_STRICT3,
547
                      'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT3,
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
548
    },
549
}