/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_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:
383
383
        size = trans.put_file('index', stream)
384
384
        return GraphIndex(trans, 'index', size)
385
385
 
 
386
    def test_clear_cache(self):
 
387
        index = self.make_index()
 
388
        # For now, we just want to make sure the api is available. As this is
 
389
        # old code, we don't really worry if it *does* anything.
 
390
        index.clear_cache()
 
391
 
386
392
    def test_open_bad_index_no_error(self):
387
393
        trans = self.get_transport()
388
394
        trans.put_bytes('name', "not an index\n")
1071
1077
        index.insert_index(0, index1)
1072
1078
        self.assertEqual([(index1, ('key', ), '')], list(index.iter_all_entries()))
1073
1079
 
 
1080
    def test_clear_cache(self):
 
1081
        log = []
 
1082
 
 
1083
        class ClearCacheProxy(object):
 
1084
 
 
1085
            def __init__(self, index):
 
1086
                self._index = index
 
1087
 
 
1088
            def __getattr__(self, name):
 
1089
                return getattr(self._index)
 
1090
 
 
1091
            def clear_cache(self):
 
1092
                log.append(self._index)
 
1093
                return self._index.clear_cache()
 
1094
 
 
1095
        index = CombinedGraphIndex([])
 
1096
        index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
 
1097
        index.insert_index(0, ClearCacheProxy(index1))
 
1098
        index2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
 
1099
        index.insert_index(1, ClearCacheProxy(index2))
 
1100
        # CombinedGraphIndex should call 'clear_cache()' on all children
 
1101
        index.clear_cache()
 
1102
        self.assertEqual(sorted([index1, index2]), sorted(log))
 
1103
 
1074
1104
    def test_iter_all_entries_empty(self):
1075
1105
        index = CombinedGraphIndex([])
1076
1106
        self.assertEqual([], list(index.iter_all_entries()))