bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2005-2011 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
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
|
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
16 |
|
17 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
18 |
from .. import ( |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
19 |
errors, |
|
4849.4.2
by John Arbash Meinel
Change from being a per-serializer attribute to being a per-repo attribute. |
20 |
fifo_cache, |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
21 |
)
|
22 |
from ..bzr import ( |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
23 |
inventory, |
|
4476.3.27
by Andrew Bennetts
Trivial improvement to test coverage in test_xml. |
24 |
xml6, |
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
25 |
xml7, |
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
26 |
xml8, |
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
27 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
28 |
from ..sixish import ( |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
29 |
BytesIO, |
30 |
)
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
31 |
from ..bzr.inventory import Inventory |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
32 |
from . import TestCase |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
33 |
import breezy.bzr.xml5 |
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
34 |
|
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
35 |
_revision_v5 = """<revision committer="Martin Pool <mbp@sourcefrog.net>" |
36 |
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
|
|
37 |
revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
|
|
|
2102.4.1
by John Arbash Meinel
Switch to using millisecond resolution in Revision XML |
38 |
timestamp="1125907235.212"
|
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
39 |
timezone="36000">
|
40 |
<message>- start splitting code for xml (de)serialization away from objects
|
|
41 |
preparatory to supporting multiple formats by a single library
|
|
42 |
</message>
|
|
43 |
<parents>
|
|
44 |
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92"/>
|
|
45 |
</parents>
|
|
46 |
</revision>
|
|
47 |
"""
|
|
48 |
||
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
49 |
_revision_v5_utc = """\ |
50 |
<revision committer="Martin Pool <mbp@sourcefrog.net>"
|
|
51 |
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
|
|
52 |
revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
|
|
|
2102.4.1
by John Arbash Meinel
Switch to using millisecond resolution in Revision XML |
53 |
timestamp="1125907235.212"
|
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
54 |
timezone="0">
|
55 |
<message>- start splitting code for xml (de)serialization away from objects
|
|
56 |
preparatory to supporting multiple formats by a single library
|
|
57 |
</message>
|
|
58 |
<parents>
|
|
59 |
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92"/>
|
|
60 |
</parents>
|
|
61 |
</revision>
|
|
62 |
"""
|
|
63 |
||
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
64 |
_committed_inv_v5 = """<inventory> |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
65 |
<file file_id="bar-20050901064931-73b4b1138abc9cd2"
|
66 |
name="bar" parent_id="TREE_ROOT"
|
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
67 |
revision="mbp@foo-123123"
|
68 |
text_sha1="A" text_size="1"/>
|
|
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
69 |
<directory name="subdir"
|
70 |
file_id="foo-20050801201819-4139aa4a272f4250"
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
71 |
parent_id="TREE_ROOT"
|
|
1092.2.21
by Robert Collins
convert name_version to revision in inventory entries |
72 |
revision="mbp@foo-00"/>
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
73 |
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134"
|
74 |
name="bar" parent_id="foo-20050801201819-4139aa4a272f4250"
|
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
75 |
revision="mbp@foo-00"
|
76 |
text_sha1="B" text_size="0"/>
|
|
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
77 |
</inventory>
|
78 |
"""
|
|
79 |
||
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
80 |
_basis_inv_v5 = """<inventory revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92"> |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
81 |
<file file_id="bar-20050901064931-73b4b1138abc9cd2"
|
82 |
name="bar" parent_id="TREE_ROOT"
|
|
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
83 |
revision="mbp@foo-123123"/>
|
84 |
<directory name="subdir"
|
|
85 |
file_id="foo-20050801201819-4139aa4a272f4250"
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
86 |
parent_id="TREE_ROOT"
|
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
87 |
revision="mbp@foo-00"/>
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
88 |
<file file_id="bar-20050824000535-6bc48cfad47ed134"
|
89 |
name="bar" parent_id="foo-20050801201819-4139aa4a272f4250"
|
|
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
90 |
revision="mbp@foo-00"/>
|
91 |
</inventory>
|
|
92 |
"""
|
|
93 |
||
|
1886.1.1
by John Arbash Meinel
Fix bug #47782, |
94 |
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
95 |
# DO NOT REFLOW THIS. Its the exact revision we want.
|
|
2102.4.1
by John Arbash Meinel
Switch to using millisecond resolution in Revision XML |
96 |
_expected_rev_v5 = """<revision committer="Martin Pool <mbp@sourcefrog.net>" format="5" inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41" revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9" timestamp="1125907235.212" timezone="36000"> |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
97 |
<message>- start splitting code for xml (de)serialization away from objects
|
98 |
preparatory to supporting multiple formats by a single library
|
|
99 |
</message>
|
|
100 |
<parents>
|
|
101 |
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92" />
|
|
102 |
</parents>
|
|
103 |
</revision>
|
|
104 |
"""
|
|
105 |
||
106 |
||
107 |
# DO NOT REFLOW THIS. Its the exact inventory we want.
|
|
108 |
_expected_inv_v5 = """<inventory format="5"> |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
109 |
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" revision="mbp@foo-123123" text_sha1="A" text_size="1" />
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
110 |
<directory file_id="foo-20050801201819-4139aa4a272f4250" name="subdir" revision="mbp@foo-00" />
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
111 |
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" text_sha1="B" text_size="0" />
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
112 |
</inventory>
|
113 |
"""
|
|
114 |
||
115 |
||
116 |
_expected_inv_v5_root = """<inventory file_id="f<" format="5" revision_id="mother!"> |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
117 |
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" parent_id="f<" revision="mbp@foo-123123" text_sha1="A" text_size="1" />
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
118 |
<directory file_id="foo-20050801201819-4139aa4a272f4250" name="subdir" parent_id="f<" revision="mbp@foo-00" />
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
119 |
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" text_sha1="B" text_size="0" />
|
120 |
<symlink file_id="link-1" name="link" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" symlink_target="a" />
|
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
121 |
</inventory>
|
122 |
"""
|
|
123 |
||
|
4476.3.27
by Andrew Bennetts
Trivial improvement to test coverage in test_xml. |
124 |
_expected_inv_v6 = """<inventory format="6" revision_id="rev_outer"> |
125 |
<directory file_id="tree-root-321" name="" revision="rev_outer" />
|
|
126 |
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
|
|
127 |
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
|
|
128 |
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
|
|
129 |
</inventory>
|
|
130 |
"""
|
|
131 |
||
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
132 |
_expected_inv_v7 = """<inventory format="7" revision_id="rev_outer"> |
133 |
<directory file_id="tree-root-321" name="" revision="rev_outer" />
|
|
134 |
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
|
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
135 |
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
|
136 |
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
|
|
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
137 |
<tree-reference file_id="nested-id" name="nested" parent_id="tree-root-321" revision="rev_outer" reference_revision="rev_inner" />
|
138 |
</inventory>
|
|
139 |
"""
|
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
140 |
|
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
141 |
_expected_rev_v8 = """<revision committer="Martin Pool <mbp@sourcefrog.net>" format="8" inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41" revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9" timestamp="1125907235.212" timezone="36000"> |
142 |
<message>- start splitting code for xml (de)serialization away from objects
|
|
143 |
preparatory to supporting multiple formats by a single library
|
|
144 |
</message>
|
|
145 |
<parents>
|
|
146 |
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92" />
|
|
147 |
</parents>
|
|
148 |
</revision>
|
|
149 |
"""
|
|
150 |
||
151 |
_expected_inv_v8 = """<inventory format="8" revision_id="rev_outer"> |
|
152 |
<directory file_id="tree-root-321" name="" revision="rev_outer" />
|
|
153 |
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
|
|
154 |
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
|
|
155 |
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
|
|
156 |
</inventory>
|
|
157 |
"""
|
|
158 |
||
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
159 |
_revision_utf8_v5 = """<revision committer="Erik Bågfors <erik@foo.net>" |
160 |
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
|
|
161 |
revision_id="erik@bågfors-02"
|
|
162 |
timestamp="1125907235.212"
|
|
163 |
timezone="36000">
|
|
164 |
<message>Include µnicode characters
|
|
165 |
</message>
|
|
166 |
<parents>
|
|
167 |
<revision_ref revision_id="erik@bågfors-01"/>
|
|
168 |
</parents>
|
|
169 |
</revision>
|
|
170 |
"""
|
|
171 |
||
172 |
_inventory_utf8_v5 = """<inventory file_id="TREé_ROOT" format="5" |
|
173 |
revision_id="erik@bågfors-02">
|
|
174 |
<file file_id="bår-01"
|
|
|
2294.1.9
by John Arbash Meinel
Minor performance improvement, use None as signal rather than ROOT_ID |
175 |
name="bår" parent_id="TREé_ROOT"
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
176 |
revision="erik@bågfors-01"/>
|
177 |
<directory name="sµbdir"
|
|
178 |
file_id="sµbdir-01"
|
|
|
2294.1.9
by John Arbash Meinel
Minor performance improvement, use None as signal rather than ROOT_ID |
179 |
parent_id="TREé_ROOT"
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
180 |
revision="erik@bågfors-01"/>
|
181 |
<file executable="yes" file_id="bår-02"
|
|
182 |
name="bår" parent_id="sµbdir-01"
|
|
183 |
revision="erik@bågfors-02"/>
|
|
184 |
</inventory>
|
|
185 |
"""
|
|
186 |
||
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
187 |
# Before revision_id was always stored as an attribute
|
188 |
_inventory_v5a = """<inventory format="5"> |
|
189 |
</inventory>
|
|
190 |
"""
|
|
191 |
||
192 |
# Before revision_id was always stored as an attribute
|
|
193 |
_inventory_v5b = """<inventory format="5" revision_id="a-rev-id"> |
|
194 |
</inventory>
|
|
195 |
"""
|
|
196 |
||
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
197 |
|
|
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
198 |
class TestSerializer(TestCase): |
199 |
"""Test XML serialization""" |
|
|
2889.1.1
by Robert Collins
* The class ``bzrlib.repofmt.knitrepo.KnitRepository3`` has been folded into |
200 |
|
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
201 |
def test_unpack_revision_5(self): |
202 |
"""Test unpacking a canned revision v5""" |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
203 |
inp = BytesIO(_revision_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
204 |
rev = breezy.bzr.xml5.serializer_v5.read_revision(inp) |
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
205 |
eq = self.assertEqual |
206 |
eq(rev.committer, |
|
207 |
"Martin Pool <mbp@sourcefrog.net>") |
|
|
1313
by Martin Pool
- rename to Revision.parent_ids to avoid confusion with old usage |
208 |
eq(len(rev.parent_ids), 1) |
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
209 |
eq(rev.timezone, 36000) |
|
1313
by Martin Pool
- rename to Revision.parent_ids to avoid confusion with old usage |
210 |
eq(rev.parent_ids[0], |
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
211 |
"mbp@sourcefrog.net-20050905063503-43948f59fa127d92") |
212 |
||
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
213 |
def test_unpack_revision_5_utc(self): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
214 |
inp = BytesIO(_revision_v5_utc) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
215 |
rev = breezy.bzr.xml5.serializer_v5.read_revision(inp) |
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
216 |
eq = self.assertEqual |
217 |
eq(rev.committer, |
|
218 |
"Martin Pool <mbp@sourcefrog.net>") |
|
219 |
eq(len(rev.parent_ids), 1) |
|
220 |
eq(rev.timezone, 0) |
|
221 |
eq(rev.parent_ids[0], |
|
222 |
"mbp@sourcefrog.net-20050905063503-43948f59fa127d92") |
|
223 |
||
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
224 |
def test_unpack_inventory_5(self): |
225 |
"""Unpack canned new-style inventory""" |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
226 |
inp = BytesIO(_committed_inv_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
227 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory(inp) |
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
228 |
eq = self.assertEqual |
229 |
eq(len(inv), 4) |
|
230 |
ie = inv['bar-20050824000535-6bc48cfad47ed134'] |
|
231 |
eq(ie.kind, 'file') |
|
|
1092.2.21
by Robert Collins
convert name_version to revision in inventory entries |
232 |
eq(ie.revision, 'mbp@foo-00') |
|
1183
by Martin Pool
- implement version 5 xml storage, and tests |
233 |
eq(ie.name, 'bar') |
234 |
eq(inv[ie.parent_id].kind, 'directory') |
|
|
1184
by Martin Pool
- fix v5 packing of inventory entries |
235 |
|
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
236 |
def test_unpack_basis_inventory_5(self): |
237 |
"""Unpack canned new-style inventory""" |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
238 |
inp = BytesIO(_basis_inv_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
239 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory(inp) |
|
1638.1.2
by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name. |
240 |
eq = self.assertEqual |
241 |
eq(len(inv), 4) |
|
242 |
eq(inv.revision_id, 'mbp@sourcefrog.net-20050905063503-43948f59fa127d92') |
|
243 |
ie = inv['bar-20050824000535-6bc48cfad47ed134'] |
|
244 |
eq(ie.kind, 'file') |
|
245 |
eq(ie.revision, 'mbp@foo-00') |
|
246 |
eq(ie.name, 'bar') |
|
247 |
eq(inv[ie.parent_id].kind, 'directory') |
|
248 |
||
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
249 |
def test_unpack_inventory_5a(self): |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
250 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory_from_string( |
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
251 |
_inventory_v5a, revision_id='test-rev-id') |
252 |
self.assertEqual('test-rev-id', inv.root.revision) |
|
253 |
||
|
4849.4.2
by John Arbash Meinel
Change from being a per-serializer attribute to being a per-repo attribute. |
254 |
def test_unpack_inventory_5a_cache_and_copy(self): |
255 |
# Passing an entry_cache should get populated with the objects
|
|
256 |
# But the returned objects should be copies if return_from_cache is
|
|
257 |
# False
|
|
258 |
entry_cache = fifo_cache.FIFOCache() |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
259 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory_from_string( |
|
4849.4.2
by John Arbash Meinel
Change from being a per-serializer attribute to being a per-repo attribute. |
260 |
_inventory_v5a, revision_id='test-rev-id', |
261 |
entry_cache=entry_cache, return_from_cache=False) |
|
262 |
for entry in inv.iter_just_entries(): |
|
263 |
key = (entry.file_id, entry.revision) |
|
264 |
if entry.file_id is inv.root.file_id: |
|
265 |
# The root id is inferred for xml v5
|
|
266 |
self.assertFalse(key in entry_cache) |
|
267 |
else: |
|
268 |
self.assertIsNot(entry, entry_cache[key]) |
|
269 |
||
270 |
def test_unpack_inventory_5a_cache_no_copy(self): |
|
271 |
# Passing an entry_cache should get populated with the objects
|
|
272 |
# The returned objects should be exact if return_from_cache is
|
|
273 |
# True
|
|
274 |
entry_cache = fifo_cache.FIFOCache() |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
275 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory_from_string( |
|
4849.4.2
by John Arbash Meinel
Change from being a per-serializer attribute to being a per-repo attribute. |
276 |
_inventory_v5a, revision_id='test-rev-id', |
277 |
entry_cache=entry_cache, return_from_cache=True) |
|
278 |
for entry in inv.iter_just_entries(): |
|
279 |
key = (entry.file_id, entry.revision) |
|
280 |
if entry.file_id is inv.root.file_id: |
|
281 |
# The root id is inferred for xml v5
|
|
282 |
self.assertFalse(key in entry_cache) |
|
283 |
else: |
|
284 |
self.assertIs(entry, entry_cache[key]) |
|
285 |
||
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
286 |
def test_unpack_inventory_5b(self): |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
287 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory_from_string( |
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
288 |
_inventory_v5b, revision_id='test-rev-id') |
289 |
self.assertEqual('a-rev-id', inv.root.revision) |
|
290 |
||
|
1184
by Martin Pool
- fix v5 packing of inventory entries |
291 |
def test_repack_inventory_5(self): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
292 |
inp = BytesIO(_committed_inv_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
293 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory(inp) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
294 |
outp = BytesIO() |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
295 |
breezy.bzr.xml5.serializer_v5.write_inventory(inv, outp) |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
296 |
self.assertEqualDiff(_expected_inv_v5, outp.getvalue()) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
297 |
inv2 = breezy.bzr.xml5.serializer_v5.read_inventory(BytesIO(outp.getvalue())) |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
298 |
self.assertEqual(inv, inv2) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
299 |
|
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
300 |
def assertRoundTrips(self, xml_string): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
301 |
inp = BytesIO(xml_string) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
302 |
inv = breezy.bzr.xml5.serializer_v5.read_inventory(inp) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
303 |
outp = BytesIO() |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
304 |
breezy.bzr.xml5.serializer_v5.write_inventory(inv, outp) |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
305 |
self.assertEqualDiff(xml_string, outp.getvalue()) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
306 |
lines = breezy.bzr.xml5.serializer_v5.write_inventory_to_lines(inv) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
307 |
outp.seek(0) |
308 |
self.assertEqual(outp.readlines(), lines) |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
309 |
inv2 = breezy.bzr.xml5.serializer_v5.read_inventory(BytesIO(outp.getvalue())) |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
310 |
self.assertEqual(inv, inv2) |
311 |
||
312 |
def tests_serialize_inventory_v5_with_root(self): |
|
313 |
self.assertRoundTrips(_expected_inv_v5_root) |
|
|
1185
by Martin Pool
- add xml round-trip test for revisions |
314 |
|
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
315 |
def check_repack_revision(self, txt): |
316 |
"""Check that repacking a revision yields the same information""" |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
317 |
inp = BytesIO(txt) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
318 |
rev = breezy.bzr.xml5.serializer_v5.read_revision(inp) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
319 |
outp = BytesIO() |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
320 |
breezy.bzr.xml5.serializer_v5.write_revision(rev, outp) |
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
321 |
outfile_contents = outp.getvalue() |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
322 |
rev2 = breezy.bzr.xml5.serializer_v5.read_revision(BytesIO(outfile_contents)) |
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
323 |
self.assertEqual(rev, rev2) |
324 |
||
|
1185
by Martin Pool
- add xml round-trip test for revisions |
325 |
def test_repack_revision_5(self): |
|
1185.16.123
by Martin Pool
Fix syntax of serializer_v5.pack_revision_to_string |
326 |
"""Round-trip revision to XML v5""" |
|
1913.1.2
by John Arbash Meinel
Add direct tests to xml serializer |
327 |
self.check_repack_revision(_revision_v5) |
328 |
||
329 |
def test_repack_revision_5_utc(self): |
|
330 |
self.check_repack_revision(_revision_v5_utc) |
|
|
1185
by Martin Pool
- add xml round-trip test for revisions |
331 |
|
|
1185.16.123
by Martin Pool
Fix syntax of serializer_v5.pack_revision_to_string |
332 |
def test_pack_revision_5(self): |
333 |
"""Pack revision to XML v5""" |
|
334 |
# fixed 20051025, revisions should have final newline
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
335 |
rev = breezy.bzr.xml5.serializer_v5.read_revision_from_string(_revision_v5) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
336 |
outp = BytesIO() |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
337 |
breezy.bzr.xml5.serializer_v5.write_revision(rev, outp) |
|
1185.16.123
by Martin Pool
Fix syntax of serializer_v5.pack_revision_to_string |
338 |
outfile_contents = outp.getvalue() |
339 |
self.assertEqual(outfile_contents[-1], '\n') |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
340 |
self.assertEqualDiff(outfile_contents, breezy.bzr.xml5.serializer_v5.write_revision_to_string(rev)) |
|
1934.1.3
by John Arbash Meinel
[merge] robert's custom XML serializer, and cleanup for benchmarks and iter_entries() differences |
341 |
self.assertEqualDiff(outfile_contents, _expected_rev_v5) |
|
1886.1.1
by John Arbash Meinel
Fix bug #47782, |
342 |
|
343 |
def test_empty_property_value(self): |
|
344 |
"""Create an empty property value check that it serializes correctly""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
345 |
s_v5 = breezy.bzr.xml5.serializer_v5 |
|
1886.1.1
by John Arbash Meinel
Fix bug #47782, |
346 |
rev = s_v5.read_revision_from_string(_revision_v5) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
347 |
outp = BytesIO() |
|
1886.1.1
by John Arbash Meinel
Fix bug #47782, |
348 |
props = {'empty':'', 'one':'one'} |
349 |
rev.properties = props |
|
350 |
txt = s_v5.write_revision_to_string(rev) |
|
351 |
new_rev = s_v5.read_revision_from_string(txt) |
|
352 |
self.assertEqual(props, new_rev.properties) |
|
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
353 |
|
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
354 |
def get_sample_inventory(self): |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
355 |
inv = Inventory('tree-root-321', revision_id='rev_outer') |
356 |
inv.add(inventory.InventoryFile('file-id', 'file', 'tree-root-321')) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
357 |
inv.add(inventory.InventoryDirectory('dir-id', 'dir', |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
358 |
'tree-root-321')) |
359 |
inv.add(inventory.InventoryLink('link-id', 'link', 'tree-root-321')) |
|
360 |
inv['tree-root-321'].revision = 'rev_outer' |
|
361 |
inv['dir-id'].revision = 'rev_outer' |
|
362 |
inv['file-id'].revision = 'rev_outer' |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
363 |
inv['file-id'].text_sha1 = 'A' |
364 |
inv['file-id'].text_size = 1 |
|
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
365 |
inv['link-id'].revision = 'rev_outer' |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
366 |
inv['link-id'].symlink_target = 'a' |
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
367 |
return inv |
368 |
||
369 |
def test_roundtrip_inventory_v7(self): |
|
370 |
inv = self.get_sample_inventory() |
|
371 |
inv.add(inventory.TreeReference('nested-id', 'nested', 'tree-root-321', |
|
372 |
'rev_outer', 'rev_inner')) |
|
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
373 |
txt = xml7.serializer_v7.write_inventory_to_string(inv) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
374 |
lines = xml7.serializer_v7.write_inventory_to_lines(inv) |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
375 |
self.assertEqual(breezy.osutils.split_lines(txt), lines) |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
376 |
self.assertEqualDiff(_expected_inv_v7, txt) |
377 |
inv2 = xml7.serializer_v7.read_inventory_from_string(txt) |
|
378 |
self.assertEqual(5, len(inv2)) |
|
379 |
for path, ie in inv.iter_entries(): |
|
380 |
self.assertEqual(ie, inv2[ie.file_id]) |
|
381 |
||
|
4476.3.27
by Andrew Bennetts
Trivial improvement to test coverage in test_xml. |
382 |
def test_roundtrip_inventory_v6(self): |
383 |
inv = self.get_sample_inventory() |
|
384 |
txt = xml6.serializer_v6.write_inventory_to_string(inv) |
|
385 |
lines = xml6.serializer_v6.write_inventory_to_lines(inv) |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
386 |
self.assertEqual(breezy.osutils.split_lines(txt), lines) |
|
4476.3.27
by Andrew Bennetts
Trivial improvement to test coverage in test_xml. |
387 |
self.assertEqualDiff(_expected_inv_v6, txt) |
388 |
inv2 = xml6.serializer_v6.read_inventory_from_string(txt) |
|
389 |
self.assertEqual(4, len(inv2)) |
|
390 |
for path, ie in inv.iter_entries(): |
|
391 |
self.assertEqual(ie, inv2[ie.file_id]) |
|
392 |
||
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
393 |
def test_wrong_format_v7(self): |
394 |
"""Can't accidentally open a file with wrong serializer""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
395 |
s_v6 = breezy.bzr.xml6.serializer_v6 |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
396 |
s_v7 = xml7.serializer_v7 |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
397 |
self.assertRaises(errors.UnexpectedInventoryFormat, |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
398 |
s_v7.read_inventory_from_string, _expected_inv_v5) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
399 |
self.assertRaises(errors.UnexpectedInventoryFormat, |
|
2100.3.2
by Aaron Bentley
Add tests for format 7, enforce number |
400 |
s_v6.read_inventory_from_string, _expected_inv_v7) |
401 |
||
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
402 |
def test_tree_reference(self): |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
403 |
s_v5 = breezy.bzr.xml5.serializer_v5 |
404 |
s_v6 = breezy.bzr.xml6.serializer_v6 |
|
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
405 |
s_v7 = xml7.serializer_v7 |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
406 |
inv = Inventory('tree-root-321', revision_id='rev-outer') |
407 |
inv.root.revision = 'root-rev' |
|
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
408 |
inv.add(inventory.TreeReference('nested-id', 'nested', 'tree-root-321', |
409 |
'rev-outer', 'rev-inner')) |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
410 |
self.assertRaises(errors.UnsupportedInventoryKind, |
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
411 |
s_v5.write_inventory_to_string, inv) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
412 |
self.assertRaises(errors.UnsupportedInventoryKind, |
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
413 |
s_v6.write_inventory_to_string, inv) |
414 |
txt = s_v7.write_inventory_to_string(inv) |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
415 |
lines = s_v7.write_inventory_to_lines(inv) |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
416 |
self.assertEqual(breezy.osutils.split_lines(txt), lines) |
|
2100.3.1
by Aaron Bentley
Start roundtripping tree-reference entries |
417 |
inv2 = s_v7.read_inventory_from_string(txt) |
418 |
self.assertEqual('tree-root-321', inv2['nested-id'].parent_id) |
|
419 |
self.assertEqual('rev-outer', inv2['nested-id'].revision) |
|
420 |
self.assertEqual('rev-inner', inv2['nested-id'].reference_revision) |
|
|
2255.6.1
by Aaron Bentley
Merge from by-reference-trees |
421 |
|
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
422 |
def test_roundtrip_inventory_v8(self): |
423 |
inv = self.get_sample_inventory() |
|
424 |
txt = xml8.serializer_v8.write_inventory_to_string(inv) |
|
425 |
inv2 = xml8.serializer_v8.read_inventory_from_string(txt) |
|
426 |
self.assertEqual(4, len(inv2)) |
|
427 |
for path, ie in inv.iter_entries(): |
|
428 |
self.assertEqual(ie, inv2[ie.file_id]) |
|
429 |
||
430 |
def test_inventory_text_v8(self): |
|
431 |
inv = self.get_sample_inventory() |
|
432 |
txt = xml8.serializer_v8.write_inventory_to_string(inv) |
|
433 |
lines = xml8.serializer_v8.write_inventory_to_lines(inv) |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
434 |
self.assertEqual(breezy.osutils.split_lines(txt), lines) |
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
435 |
self.assertEqualDiff(_expected_inv_v8, txt) |
436 |
||
|
3311.3.3
by Aaron Bentley
Handle format 5 revision |
437 |
def test_revision_text_v6(self): |
438 |
"""Pack revision to XML v6""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
439 |
rev = breezy.bzr.xml6.serializer_v6.read_revision_from_string( |
|
3311.3.3
by Aaron Bentley
Handle format 5 revision |
440 |
_expected_rev_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
441 |
serialized = breezy.bzr.xml6.serializer_v6.write_revision_to_string(rev) |
|
3311.3.3
by Aaron Bentley
Handle format 5 revision |
442 |
self.assertEqualDiff(serialized, _expected_rev_v5) |
443 |
||
444 |
def test_revision_text_v7(self): |
|
445 |
"""Pack revision to XML v7""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
446 |
rev = breezy.bzr.xml7.serializer_v7.read_revision_from_string( |
|
3311.3.3
by Aaron Bentley
Handle format 5 revision |
447 |
_expected_rev_v5) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
448 |
serialized = breezy.bzr.xml7.serializer_v7.write_revision_to_string(rev) |
|
3311.3.3
by Aaron Bentley
Handle format 5 revision |
449 |
self.assertEqualDiff(serialized, _expected_rev_v5) |
450 |
||
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
451 |
def test_revision_text_v8(self): |
452 |
"""Pack revision to XML v8""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
453 |
rev = breezy.bzr.xml8.serializer_v8.read_revision_from_string( |
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
454 |
_expected_rev_v8) |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
455 |
serialized = breezy.bzr.xml8.serializer_v8.write_revision_to_string(rev) |
|
3311.3.2
by Aaron Bentley
Implement version numbers for format 8 |
456 |
self.assertEqualDiff(serialized, _expected_rev_v8) |
457 |
||
|
2249.5.4
by John Arbash Meinel
When reading XML, always return utf-8 revision ids. |
458 |
def test_revision_ids_are_utf8(self): |
459 |
"""Parsed revision_ids should all be utf-8 strings, not unicode.""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
460 |
s_v5 = breezy.bzr.xml5.serializer_v5 |
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
461 |
rev = s_v5.read_revision_from_string(_revision_utf8_v5) |
462 |
self.assertEqual('erik@b\xc3\xa5gfors-02', rev.revision_id) |
|
|
2249.5.4
by John Arbash Meinel
When reading XML, always return utf-8 revision ids. |
463 |
self.assertIsInstance(rev.revision_id, str) |
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
464 |
self.assertEqual(['erik@b\xc3\xa5gfors-01'], rev.parent_ids) |
|
2249.5.4
by John Arbash Meinel
When reading XML, always return utf-8 revision ids. |
465 |
for parent_id in rev.parent_ids: |
466 |
self.assertIsInstance(parent_id, str) |
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
467 |
self.assertEqual(u'Include \xb5nicode characters\n', rev.message) |
468 |
self.assertIsInstance(rev.message, unicode) |
|
|
2249.5.4
by John Arbash Meinel
When reading XML, always return utf-8 revision ids. |
469 |
|
470 |
# ie.revision should either be None or a utf-8 revision id
|
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
471 |
inv = s_v5.read_inventory_from_string(_inventory_utf8_v5) |
472 |
rev_id_1 = u'erik@b\xe5gfors-01'.encode('utf8') |
|
473 |
rev_id_2 = u'erik@b\xe5gfors-02'.encode('utf8') |
|
|
2294.1.10
by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass |
474 |
fid_root = u'TRE\xe9_ROOT'.encode('utf8') |
475 |
fid_bar1 = u'b\xe5r-01'.encode('utf8') |
|
476 |
fid_sub = u's\xb5bdir-01'.encode('utf8') |
|
477 |
fid_bar2 = u'b\xe5r-02'.encode('utf8') |
|
|
2889.1.1
by Robert Collins
* The class ``bzrlib.repofmt.knitrepo.KnitRepository3`` has been folded into |
478 |
expected = [(u'', fid_root, None, rev_id_2), |
|
2294.1.6
by John Arbash Meinel
Include parent_id checks in the xml serializer tests. |
479 |
(u'b\xe5r', fid_bar1, fid_root, rev_id_1), |
480 |
(u's\xb5bdir', fid_sub, fid_root, rev_id_1), |
|
481 |
(u's\xb5bdir/b\xe5r', fid_bar2, fid_sub, rev_id_2), |
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
482 |
]
|
483 |
self.assertEqual(rev_id_2, inv.revision_id) |
|
484 |
self.assertIsInstance(inv.revision_id, str) |
|
485 |
||
486 |
actual = list(inv.iter_entries_by_dir()) |
|
|
2294.1.6
by John Arbash Meinel
Include parent_id checks in the xml serializer tests. |
487 |
for ((exp_path, exp_file_id, exp_parent_id, exp_rev_id), |
488 |
(act_path, act_ie)) in zip(expected, actual): |
|
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
489 |
self.assertEqual(exp_path, act_path) |
490 |
self.assertIsInstance(act_path, unicode) |
|
491 |
self.assertEqual(exp_file_id, act_ie.file_id) |
|
|
2294.1.10
by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass |
492 |
self.assertIsInstance(act_ie.file_id, str) |
|
2294.1.6
by John Arbash Meinel
Include parent_id checks in the xml serializer tests. |
493 |
self.assertEqual(exp_parent_id, act_ie.parent_id) |
494 |
if exp_parent_id is not None: |
|
|
2294.1.10
by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass |
495 |
self.assertIsInstance(act_ie.parent_id, str) |
|
2294.1.5
by John Arbash Meinel
Fix Inventory.iter_entries_by_dir to return Unicode paths, |
496 |
self.assertEqual(exp_rev_id, act_ie.revision) |
497 |
if exp_rev_id is not None: |
|
498 |
self.assertIsInstance(act_ie.revision, str) |
|
499 |
||
500 |
self.assertEqual(len(expected), len(actual)) |
|
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
501 |
|
502 |
||
503 |
class TestEncodeAndEscape(TestCase): |
|
504 |
"""Whitebox testing of the _encode_and_escape function.""" |
|
505 |
||
506 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
507 |
super(TestEncodeAndEscape, self).setUp() |
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
508 |
# Keep the cache clear before and after the test
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
509 |
breezy.bzr.xml_serializer._clear_cache() |
510 |
self.addCleanup(breezy.bzr.xml_serializer._clear_cache) |
|
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
511 |
|
512 |
def test_simple_ascii(self): |
|
513 |
# _encode_and_escape always appends a final ", because these parameters
|
|
514 |
# are being used in xml attributes, and by returning it now, we have to
|
|
515 |
# do fewer string operations later.
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
516 |
val = breezy.bzr.xml_serializer.encode_and_escape('foo bar') |
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
517 |
self.assertEqual('foo bar"', val) |
518 |
# The second time should be cached
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
519 |
val2 = breezy.bzr.xml_serializer.encode_and_escape('foo bar') |
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
520 |
self.assertIs(val2, val) |
521 |
||
522 |
def test_ascii_with_xml(self): |
|
523 |
self.assertEqual('&'"<>"', |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
524 |
breezy.bzr.xml_serializer.encode_and_escape('&\'"<>')) |
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
525 |
|
526 |
def test_utf8_with_xml(self): |
|
527 |
# u'\xb5\xe5&\u062c'
|
|
528 |
utf8_str = '\xc2\xb5\xc3\xa5&\xd8\xac' |
|
529 |
self.assertEqual('µå&ج"', |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
530 |
breezy.bzr.xml_serializer.encode_and_escape(utf8_str)) |
|
2249.5.10
by John Arbash Meinel
Make sure xml5 can handle unicode or utf8 strings |
531 |
|
532 |
def test_unicode(self): |
|
533 |
uni_str = u'\xb5\xe5&\u062c' |
|
534 |
self.assertEqual('µå&ج"', |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
535 |
breezy.bzr.xml_serializer.encode_and_escape(uni_str)) |
|
5671.2.4
by Jelmer Vernooij
Fix unescape_xml test. |
536 |
|
537 |
||
538 |
class TestMisc(TestCase): |
|
539 |
||
540 |
def test_unescape_xml(self): |
|
541 |
"""We get some kind of error when malformed entities are passed""" |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
542 |
self.assertRaises(KeyError, breezy.bzr.xml8._unescape_xml, 'foo&bar;') |