/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: Jelmer Vernooij
  • Date: 2009-02-25 14:36:59 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4049.
  • Revision ID: jelmer@samba.org-20090225143659-vx6cbqtmyicuzfyf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
558
558
        # not create a new transport request, and should return False (cannot
559
559
        # be in the index) - even when the byte location we ask for is outside
560
560
        # the parsed region
561
 
        # 
 
561
        #
562
562
        result = index._lookup_keys_via_location([(4000, self.make_key(40))])
563
563
        self.assertEqual(
564
564
            [((4000, self.make_key(40)),
922
922
        index = self.make_index(nodes=[(('key', ), 'value', ())])
923
923
        index.validate()
924
924
 
 
925
    # XXX: external_references tests are duplicated in test_btree_index.  We
 
926
    # probably should have per_graph_index tests...
 
927
    def test_external_references_no_refs(self):
 
928
        index = self.make_index(ref_lists=0, nodes=[])
 
929
        self.assertRaises(ValueError, index.external_references, 0)
 
930
 
 
931
    def test_external_references_no_results(self):
 
932
        index = self.make_index(ref_lists=1, nodes=[
 
933
            (('key',), 'value', ([],))])
 
934
        self.assertEqual(set(), index.external_references(0))
 
935
 
 
936
    def test_external_references_missing_ref(self):
 
937
        missing_key = ('missing',)
 
938
        index = self.make_index(ref_lists=1, nodes=[
 
939
            (('key',), 'value', ([missing_key],))])
 
940
        self.assertEqual(set([missing_key]), index.external_references(0))
 
941
 
 
942
    def test_external_references_multiple_ref_lists(self):
 
943
        missing_key = ('missing',)
 
944
        index = self.make_index(ref_lists=2, nodes=[
 
945
            (('key',), 'value', ([], [missing_key]))])
 
946
        self.assertEqual(set([]), index.external_references(0))
 
947
        self.assertEqual(set([missing_key]), index.external_references(1))
 
948
 
 
949
    def test_external_references_two_records(self):
 
950
        index = self.make_index(ref_lists=1, nodes=[
 
951
            (('key-1',), 'value', ([('key-2',)],)),
 
952
            (('key-2',), 'value', ([],)),
 
953
            ])
 
954
        self.assertEqual(set([]), index.external_references(0))
 
955
 
925
956
 
926
957
class TestCombinedGraphIndex(TestCaseWithMemoryTransport):
927
958
 
1047
1078
        self.assertEqual(set([(index1, ('name', ), 'data', ((('ref', ), ), )),
1048
1079
            (index2, ('ref', ), 'refdata', ((), ))]),
1049
1080
            set(index.iter_entries([('name', ), ('ref', )])))
1050
 
 
 
1081
 
1051
1082
    def test_iter_all_keys_dup_entry(self):
1052
1083
        index1 = self.make_index('1', 1, nodes=[
1053
1084
            (('name', ), 'data', ([('ref', )], )),
1058
1089
        self.assertEqual(set([(index1, ('name', ), 'data', ((('ref',),),)),
1059
1090
            (index1, ('ref', ), 'refdata', ((), ))]),
1060
1091
            set(index.iter_entries([('name', ), ('ref', )])))
1061
 
 
 
1092
 
1062
1093
    def test_iter_missing_entry_empty(self):
1063
1094
        index = CombinedGraphIndex([])
1064
1095
        self.assertEqual([], list(index.iter_entries([('a', )])))
1073
1104
        index2 = self.make_index('2')
1074
1105
        index = CombinedGraphIndex([index1, index2])
1075
1106
        self.assertEqual([], list(index.iter_entries([('a', )])))
1076
 
 
 
1107
 
1077
1108
    def test_iter_entry_present_one_index_only(self):
1078
1109
        index1 = self.make_index('1', nodes=[(('key', ), '', ())])
1079
1110
        index2 = self.make_index('2', nodes=[])