~bzr-pqm/bzr/bzr.dev

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