38
from bzrlib.serializer import (
39
format_registry as serializer_format_registry,
37
41
from bzrlib.tests import (
38
43
TestCaseWithTransport,
46
from bzrlib.plugins.weave_fmt import xml4
41
47
from bzrlib.plugins.weave_fmt.bzrdir import (
268
274
self.assertTrue(is_compatible(repo_a, repo_b))
269
275
self.assertEqual(InterWeaveRepo,
270
276
InterRepository.get(repo_a, repo_b).__class__)
279
_working_inventory_v4 = """<inventory file_id="TREE_ROOT">
280
<entry file_id="bar-20050901064931-73b4b1138abc9cd2" kind="file" name="bar" parent_id="TREE_ROOT" />
281
<entry file_id="foo-20050801201819-4139aa4a272f4250" kind="directory" name="foo" parent_id="TREE_ROOT" />
282
<entry file_id="bar-20050824000535-6bc48cfad47ed134" kind="file" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" />
286
_revision_v4 = """<revision committer="Martin Pool <mbp@sourcefrog.net>"
287
inventory_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
288
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
289
revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
290
timestamp="1125907235.212"
292
<message>- start splitting code for xml (de)serialization away from objects
293
preparatory to supporting multiple formats by a single library
296
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92" revision_sha1="7bdf4cc8c5bdac739f8cf9b10b78cf4b68f915ff" />
302
class TestSerializer(TestCase):
303
"""Test serializer"""
305
def test_registry(self):
306
self.assertIs(xml4.serializer_v4,
307
serializer_format_registry.get('4'))
309
def test_canned_inventory(self):
310
"""Test unpacked a canned inventory v4 file."""
311
inp = StringIO(_working_inventory_v4)
312
inv = xml4.serializer_v4.read_inventory(inp)
313
self.assertEqual(len(inv), 4)
314
self.assert_('bar-20050901064931-73b4b1138abc9cd2' in inv)
316
def test_unpack_revision(self):
317
"""Test unpacking a canned revision v4"""
318
inp = StringIO(_revision_v4)
319
rev = xml4.serializer_v4.read_revision(inp)
320
eq = self.assertEqual
322
"Martin Pool <mbp@sourcefrog.net>")
324
"mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9")
325
eq(len(rev.parent_ids), 1)
326
eq(rev.parent_ids[0],
327
"mbp@sourcefrog.net-20050905063503-43948f59fa127d92")