~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-12 00:01:34 UTC
  • mfrom: (5582.10.97 weave-plugin)
  • Revision ID: pqm@pqm.ubuntu.com-20110312000134-exy10w8ctjs8tpiu
Tags: upstream-2.4.0~beta1~bzr5718
(jelmer) Add Prober.known_formats() in favour of
 BzrDirFormat.register_format() and ControlDirFormat.register_format().
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    )
27
27
from bzrlib.tests import TestCase
28
28
from bzrlib.inventory import Inventory
29
 
from bzrlib.xml4 import serializer_v4
30
29
import bzrlib.xml5
31
30
 
32
 
_working_inventory_v4 = """<inventory file_id="TREE_ROOT">
33
 
<entry file_id="bar-20050901064931-73b4b1138abc9cd2" kind="file" name="bar" parent_id="TREE_ROOT" />
34
 
<entry file_id="foo-20050801201819-4139aa4a272f4250" kind="directory" name="foo" parent_id="TREE_ROOT" />
35
 
<entry file_id="bar-20050824000535-6bc48cfad47ed134" kind="file" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" />
36
 
</inventory>"""
37
 
 
38
 
 
39
 
_revision_v4 = """<revision committer="Martin Pool &lt;mbp@sourcefrog.net&gt;"
40
 
    inventory_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
41
 
    inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
42
 
    revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
43
 
    timestamp="1125907235.212"
44
 
    timezone="36000">
45
 
<message>- start splitting code for xml (de)serialization away from objects
46
 
  preparatory to supporting multiple formats by a single library
47
 
</message>
48
 
<parents>
49
 
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92" revision_sha1="7bdf4cc8c5bdac739f8cf9b10b78cf4b68f915ff" />
50
 
</parents>
51
 
</revision>
52
 
"""
53
 
 
54
31
_revision_v5 = """<revision committer="Martin Pool &lt;mbp@sourcefrog.net&gt;"
55
32
    inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
56
33
    revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
217
194
class TestSerializer(TestCase):
218
195
    """Test XML serialization"""
219
196
 
220
 
    def test_canned_inventory(self):
221
 
        """Test unpacked a canned inventory v4 file."""
222
 
        inp = StringIO(_working_inventory_v4)
223
 
        inv = serializer_v4.read_inventory(inp)
224
 
        self.assertEqual(len(inv), 4)
225
 
        self.assert_('bar-20050901064931-73b4b1138abc9cd2' in inv)
226
 
 
227
 
    def test_unpack_revision(self):
228
 
        """Test unpacking a canned revision v4"""
229
 
        inp = StringIO(_revision_v4)
230
 
        rev = serializer_v4.read_revision(inp)
231
 
        eq = self.assertEqual
232
 
        eq(rev.committer,
233
 
           "Martin Pool <mbp@sourcefrog.net>")
234
 
        eq(rev.inventory_id,
235
 
           "mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9")
236
 
        eq(len(rev.parent_ids), 1)
237
 
        eq(rev.parent_ids[0],
238
 
           "mbp@sourcefrog.net-20050905063503-43948f59fa127d92")
239
 
 
240
197
    def test_unpack_revision_5(self):
241
198
        """Test unpacking a canned revision v5"""
242
199
        inp = StringIO(_revision_v5)