/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_btree_index.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-19 15:39:25 UTC
  • mto: This revision was merged to the branch mainline in revision 4758.
  • Revision ID: john@arbash-meinel.com-20091019153925-pkvnaoho6a2aawj7
Start exposing an GraphIndex.clear_cache() member.
This is exposed on GraphIndex, CombinedGraphIndex and BTreeGraphIndex.

Show diffs side-by-side

added added

removed removed

Lines of Context:
639
639
        size = trans.put_file('index', stream)
640
640
        return btree_index.BTreeGraphIndex(trans, 'index', size)
641
641
 
 
642
    def test_clear_cache(self):
 
643
        nodes = self.make_nodes(160, 2, 2)
 
644
        index = self.make_index(ref_lists=2, key_elements=2, nodes=nodes)
 
645
        self.assertEqual(1, len(list(index.iter_entries([nodes[30][0]]))))
 
646
        self.assertEqual([1, 4], index._row_lengths)
 
647
        self.assertIsNot(None, index._root_node)
 
648
        # NOTE: we don't want to affect the _internal_node_cache, as we expect
 
649
        #       it will be small, and if we ever do touch this index again, it
 
650
        #       will save round-trips. However, it requires a 3-level tree to
 
651
        #       test this...
 
652
        # self.assertTrue(len(index._internal_node_cache) > 0)
 
653
        self.assertTrue(len(index._leaf_node_cache) > 0)
 
654
        index.clear_cache()
 
655
        # We don't touch _root_node or _internal_node_cache, both should be
 
656
        # small, and can save a round trip or two
 
657
        self.assertIsNot(None, index._root_node)
 
658
        # self.assertTrue(len(index._internal_node_cache) > 0)
 
659
        self.assertEqual(0, len(index._leaf_node_cache))
 
660
 
642
661
    def test_trivial_constructor(self):
643
662
        transport = get_transport('trace+' + self.get_url(''))
644
663
        index = btree_index.BTreeGraphIndex(transport, 'index', None)