~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-19 15:23:08 UTC
  • mto: (5582.12.2 weave-plugin)
  • mto: This revision was merged to the branch mainline in revision 5718.
  • Revision ID: jelmer@samba.org-20110219152308-5shhc4rj0ez4oa12
move xml4 to weave plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
"""
22
22
 
 
23
from cStringIO import StringIO
23
24
from stat import S_ISDIR
24
25
import sys
25
26
 
34
35
    InterRepository,
35
36
    Repository,
36
37
    )
 
38
from bzrlib.serializer import (
 
39
    format_registry as serializer_format_registry,
 
40
    )
37
41
from bzrlib.tests import (
 
42
    TestCase,
38
43
    TestCaseWithTransport,
39
44
    )
40
45
 
 
46
from bzrlib.plugins.weave_fmt import xml4
41
47
from bzrlib.plugins.weave_fmt.bzrdir import (
42
48
    BzrDirFormat6,
43
49
    )
268
274
                self.assertTrue(is_compatible(repo_a, repo_b))
269
275
        self.assertEqual(InterWeaveRepo,
270
276
                         InterRepository.get(repo_a, repo_b).__class__)
 
277
 
 
278
 
 
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" />
 
283
</inventory>"""
 
284
 
 
285
 
 
286
_revision_v4 = """<revision committer="Martin Pool &lt;mbp@sourcefrog.net&gt;"
 
287
    inventory_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
 
288
    inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
 
289
    revision_id="mbp@sourcefrog.net-20050905080035-e0439293f8b6b9f9"
 
290
    timestamp="1125907235.212"
 
291
    timezone="36000">
 
292
<message>- start splitting code for xml (de)serialization away from objects
 
293
  preparatory to supporting multiple formats by a single library
 
294
</message>
 
295
<parents>
 
296
<revision_ref revision_id="mbp@sourcefrog.net-20050905063503-43948f59fa127d92" revision_sha1="7bdf4cc8c5bdac739f8cf9b10b78cf4b68f915ff" />
 
297
</parents>
 
298
</revision>
 
299
"""
 
300
 
 
301
 
 
302
class TestSerializer(TestCase):
 
303
    """Test serializer"""
 
304
 
 
305
    def test_registry(self):
 
306
        self.assertIs(xml4.serializer_v4,
 
307
                      serializer_format_registry.get('4'))
 
308
 
 
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)
 
315
 
 
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
 
321
        eq(rev.committer,
 
322
           "Martin Pool <mbp@sourcefrog.net>")
 
323
        eq(rev.inventory_id,
 
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")
 
328
 
 
329