~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 03:58:20 UTC
  • mfrom: (4963 +trunk)
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115035820-ilb3t36swgzq6v1l
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from bzrlib import (
20
20
    errors,
 
21
    fifo_cache,
21
22
    inventory,
22
23
    xml6,
23
24
    xml7,
290
291
                _inventory_v5a, revision_id='test-rev-id')
291
292
        self.assertEqual('test-rev-id', inv.root.revision)
292
293
 
 
294
    def test_unpack_inventory_5a_cache_and_copy(self):
 
295
        # Passing an entry_cache should get populated with the objects
 
296
        # But the returned objects should be copies if return_from_cache is
 
297
        # False
 
298
        entry_cache = fifo_cache.FIFOCache()
 
299
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
 
300
            _inventory_v5a, revision_id='test-rev-id',
 
301
            entry_cache=entry_cache, return_from_cache=False)
 
302
        for entry in inv.iter_just_entries():
 
303
            key = (entry.file_id, entry.revision)
 
304
            if entry.file_id is inv.root.file_id:
 
305
                # The root id is inferred for xml v5
 
306
                self.assertFalse(key in entry_cache)
 
307
            else:
 
308
                self.assertIsNot(entry, entry_cache[key])
 
309
 
 
310
    def test_unpack_inventory_5a_cache_no_copy(self):
 
311
        # Passing an entry_cache should get populated with the objects
 
312
        # The returned objects should be exact if return_from_cache is
 
313
        # True
 
314
        entry_cache = fifo_cache.FIFOCache()
 
315
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
 
316
            _inventory_v5a, revision_id='test-rev-id',
 
317
            entry_cache=entry_cache, return_from_cache=True)
 
318
        for entry in inv.iter_just_entries():
 
319
            key = (entry.file_id, entry.revision)
 
320
            if entry.file_id is inv.root.file_id:
 
321
                # The root id is inferred for xml v5
 
322
                self.assertFalse(key in entry_cache)
 
323
            else:
 
324
                self.assertIs(entry, entry_cache[key])
 
325
 
293
326
    def test_unpack_inventory_5b(self):
294
327
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
295
328
                _inventory_v5b, revision_id='test-rev-id')