bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
1 |
# Copyright (C) 2008 Aaron Bentley <aaron@aaronbentley.com>
|
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 |
||
|
0.12.9
by Aaron Bentley
Simplify tests |
17 |
import os |
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
18 |
|
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
19 |
from bzrlib import pack, transform |
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
20 |
from bzrlib.plugins.shelf2.serialize_transform import (serialize, deserialize) |
|
0.12.9
by Aaron Bentley
Simplify tests |
21 |
from bzrlib import tests |
22 |
||
23 |
||
24 |
class TestSerializeTransform(tests.TestCaseWithTransport): |
|
25 |
||
26 |
def get_two_previews(self, tree): |
|
27 |
tt = transform.TransformPreview(tree) |
|
28 |
self.addCleanup(tt.finalize) |
|
29 |
tt2 = transform.TransformPreview(tree) |
|
30 |
self.addCleanup(tt2.finalize) |
|
31 |
return tt, tt2 |
|
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
32 |
|
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
33 |
@staticmethod
|
34 |
def reserialize(tt, tt2): |
|
35 |
serializer = pack.ContainerSerialiser() |
|
36 |
parser = pack.ContainerPushParser() |
|
37 |
parser.accept_bytes(serializer.begin()) |
|
38 |
for bytes in serialize(tt, serializer): |
|
39 |
parser.accept_bytes(bytes) |
|
40 |
parser.accept_bytes(serializer.end()) |
|
41 |
deserialize(tt2, iter(parser.read_pending_records())) |
|
42 |
||
|
0.12.8
by Aaron Bentley
Test deleting and unversioning |
43 |
def test_roundtrip_creation(self): |
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
44 |
tree = self.make_branch_and_tree('.') |
|
0.12.9
by Aaron Bentley
Simplify tests |
45 |
tt, tt2 = self.get_two_previews(tree) |
|
0.12.1
by Aaron Bentley
Initial bencode-based encoding |
46 |
tt.new_file(u'foo\u1234', tt.root, 'bar', 'baz', True) |
|
0.12.6
by Aaron Bentley
Support serializing/deserializing directories |
47 |
tt.new_directory('qux', tt.root, 'quxx') |
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
48 |
self.reserialize(tt, tt2) |
|
0.12.6
by Aaron Bentley
Support serializing/deserializing directories |
49 |
self.assertEqual(3, tt2._id_number) |
50 |
self.assertEqual({'new-1': u'foo\u1234', |
|
51 |
'new-2': 'qux'}, tt2._new_name) |
|
52 |
self.assertEqual({'new-1': 'baz', 'new-2': 'quxx'}, tt2._new_id) |
|
53 |
self.assertEqual({'new-1': tt.root, 'new-2': tt.root}, tt2._new_parent) |
|
54 |
self.assertEqual({'baz': 'new-1', 'quxx': 'new-2'}, tt2._r_new_id) |
|
|
0.12.7
by Aaron Bentley
Get executability under test. |
55 |
self.assertEqual({'new-1': True}, tt2._new_executability) |
|
0.12.6
by Aaron Bentley
Support serializing/deserializing directories |
56 |
self.assertEqual({'new-1': 'file', |
57 |
'new-2': 'directory'}, tt2._new_contents) |
|
|
0.12.5
by Aaron Bentley
Test file content |
58 |
foo_limbo = open(tt2._limbo_name('new-1'), 'rb') |
59 |
try: |
|
60 |
foo_content = foo_limbo.read() |
|
61 |
finally: |
|
62 |
foo_limbo.close() |
|
63 |
self.assertEqual('bar', foo_content) |
|
|
0.12.8
by Aaron Bentley
Test deleting and unversioning |
64 |
|
|
0.12.10
by Aaron Bentley
Implement symlink serialization |
65 |
def test_symlink_creation(self): |
66 |
self.requireFeature(tests.SymlinkFeature) |
|
67 |
tree = self.make_branch_and_tree('.') |
|
68 |
tt, tt2 = self.get_two_previews(tree) |
|
69 |
tt.new_symlink('foo', tt.root, 'bar') |
|
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
70 |
self.reserialize(tt, tt2) |
|
0.12.10
by Aaron Bentley
Implement symlink serialization |
71 |
foo_content = os.readlink(tt2._limbo_name('new-1')) |
72 |
self.assertEqual('bar', foo_content) |
|
73 |
||
|
0.12.8
by Aaron Bentley
Test deleting and unversioning |
74 |
def test_roundtrip_destruction(self): |
75 |
tree = self.make_branch_and_tree('.') |
|
76 |
self.build_tree([u'foo\u1234', 'bar']) |
|
77 |
tree.add([u'foo\u1234', 'bar'], ['foo-id', 'bar-id']) |
|
|
0.12.9
by Aaron Bentley
Simplify tests |
78 |
tt, tt2 = self.get_two_previews(tree) |
|
0.12.8
by Aaron Bentley
Test deleting and unversioning |
79 |
foo_trans_id = tt.trans_id_tree_file_id('foo-id') |
80 |
tt.unversion_file(foo_trans_id) |
|
81 |
bar_trans_id = tt.trans_id_tree_file_id('bar-id') |
|
82 |
tt.delete_contents(bar_trans_id) |
|
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
83 |
self.reserialize(tt, tt2) |
|
0.12.8
by Aaron Bentley
Test deleting and unversioning |
84 |
self.assertEqual({u'foo\u1234': foo_trans_id, |
85 |
'bar': bar_trans_id, |
|
86 |
'': tt.root}, tt2._tree_path_ids) |
|
87 |
self.assertEqual({foo_trans_id: u'foo\u1234', |
|
88 |
bar_trans_id: 'bar', |
|
89 |
tt.root: ''}, tt2._tree_id_paths) |
|
90 |
self.assertEqual(set([foo_trans_id]), tt2._removed_id) |
|
91 |
self.assertEqual(set([bar_trans_id]), tt2._removed_contents) |
|
|
0.12.11
by Aaron Bentley
Some tweakage |
92 |
|
93 |
def test_roundtrip_missing(self): |
|
94 |
tree = self.make_branch_and_tree('.') |
|
95 |
tt, tt2 = self.get_two_previews(tree) |
|
96 |
boo_trans_id = tt.trans_id_file_id('boo') |
|
|
0.13.1
by Aaron Bentley
Serialization does not dictate contents of beginning of file. |
97 |
self.reserialize(tt, tt2) |
|
0.12.11
by Aaron Bentley
Some tweakage |
98 |
self.assertEqual({'boo': boo_trans_id}, tt2._non_present_ids) |