~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

merge 2.0 branch rev 4647

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from bzrlib import (
20
20
    errors,
21
21
    inventory,
 
22
    xml6,
22
23
    xml7,
23
24
    xml8,
24
25
    serializer,
139
140
</inventory>
140
141
"""
141
142
 
 
143
_expected_inv_v6 = """<inventory format="6" revision_id="rev_outer">
 
144
<directory file_id="tree-root-321" name="" revision="rev_outer" />
 
145
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
 
146
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
 
147
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
 
148
</inventory>
 
149
"""
 
150
 
142
151
_expected_inv_v7 = """<inventory format="7" revision_id="rev_outer">
143
152
<directory file_id="tree-root-321" name="" revision="rev_outer" />
144
153
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
377
386
        for path, ie in inv.iter_entries():
378
387
            self.assertEqual(ie, inv2[ie.file_id])
379
388
 
 
389
    def test_roundtrip_inventory_v6(self):
 
390
        inv = self.get_sample_inventory()
 
391
        txt = xml6.serializer_v6.write_inventory_to_string(inv)
 
392
        lines = xml6.serializer_v6.write_inventory_to_lines(inv)
 
393
        self.assertEqual(bzrlib.osutils.split_lines(txt), lines)
 
394
        self.assertEqualDiff(_expected_inv_v6, txt)
 
395
        inv2 = xml6.serializer_v6.read_inventory_from_string(txt)
 
396
        self.assertEqual(4, len(inv2))
 
397
        for path, ie in inv.iter_entries():
 
398
            self.assertEqual(ie, inv2[ie.file_id])
 
399
 
380
400
    def test_wrong_format_v7(self):
381
401
        """Can't accidentally open a file with wrong serializer"""
382
402
        s_v6 = bzrlib.xml6.serializer_v6