~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_chk_map.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for maps built on a CHK versionedfiles facility."""
18
18
 
19
 
from itertools import izip
20
 
 
21
19
from bzrlib import (
22
20
    chk_map,
23
21
    errors,
467
465
        # updated key.
468
466
        self.assertEqual(new_root, chkmap._root_node._key)
469
467
 
 
468
    def test_apply_delete_to_internal_node(self):
 
469
        # applying a delta should be convert an internal root node to a leaf
 
470
        # node if the delta shrinks the map enough.
 
471
        store = self.get_chk_bytes()
 
472
        chkmap = CHKMap(store, None)
 
473
        # Add three items: 2 small enough to fit in one node, and one huge to
 
474
        # force multiple nodes.
 
475
        chkmap._root_node.set_maximum_size(100)
 
476
        chkmap.map(('small',), 'value')
 
477
        chkmap.map(('little',), 'value')
 
478
        chkmap.map(('very-big',), 'x' * 100)
 
479
        # (Check that we have constructed the scenario we want to test)
 
480
        self.assertIsInstance(chkmap._root_node, InternalNode)
 
481
        # Delete the huge item so that the map fits in one node again.
 
482
        delta = [(('very-big',), None, None)]
 
483
        chkmap.apply_delta(delta)
 
484
        self.assertCanonicalForm(chkmap)
 
485
        self.assertIsInstance(chkmap._root_node, LeafNode)
 
486
 
470
487
    def test_apply_new_keys_must_be_new(self):
471
488
        # applying a delta (None, "a", "b") to a map with 'a' in it generates
472
489
        # an error.