/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-08-13 19:56:26 UTC
  • mto: This revision was merged to the branch mainline in revision 4613.
  • Revision ID: john@arbash-meinel.com-20090813195626-tlsu5cexc1q8lzmr
Name the specific index api _find_ancestors, and the public CombinedGraphIndex api find_ancestry()

Show diffs side-by-side

added added

removed removed

Lines of Context:
981
981
            ])
982
982
        self.assertEqual(set([]), index.external_references(0))
983
983
 
984
 
    def test_get_ancestry_one_page(self):
 
984
    def test__find_ancestors_one_page(self):
985
985
        key1 = ('key-1',)
986
986
        key2 = ('key-2',)
987
987
        index = self.make_index(ref_lists=1, key_elements=1, nodes=[
990
990
            ])
991
991
        parent_map = {}
992
992
        missing_keys = set()
993
 
        search_keys = index.get_ancestry([key1], 0, parent_map, missing_keys)
 
993
        search_keys = index._find_ancestors([key1], 0, parent_map, missing_keys)
994
994
        self.assertEqual({key1: (key2,), key2: ()}, parent_map)
995
995
        self.assertEqual(set(), missing_keys)
996
996
        self.assertEqual(set(), search_keys)
997
997
 
998
 
    def test_get_ancestry_one_page_w_missing(self):
 
998
    def test__find_ancestors_one_page_w_missing(self):
999
999
        key1 = ('key-1',)
1000
1000
        key2 = ('key-2',)
1001
1001
        key3 = ('key-3',)
1005
1005
            ])
1006
1006
        parent_map = {}
1007
1007
        missing_keys = set()
1008
 
        search_keys = index.get_ancestry([key2, key3], 0, parent_map,
1009
 
                                         missing_keys)
 
1008
        search_keys = index._find_ancestors([key2, key3], 0, parent_map,
 
1009
                                            missing_keys)
1010
1010
        self.assertEqual({key2: ()}, parent_map)
1011
1011
        # we know that key3 is missing because we read the page that it would
1012
1012
        # otherwise be on
1013
1013
        self.assertEqual(set([key3]), missing_keys)
1014
1014
        self.assertEqual(set(), search_keys)
1015
1015
 
1016
 
    def test_get_ancestry_one_parent_missing(self):
 
1016
    def test__find_ancestors_one_parent_missing(self):
1017
1017
        key1 = ('key-1',)
1018
1018
        key2 = ('key-2',)
1019
1019
        key3 = ('key-3',)
1023
1023
            ])
1024
1024
        parent_map = {}
1025
1025
        missing_keys = set()
1026
 
        search_keys = index.get_ancestry([key1], 0, parent_map,
1027
 
                                         missing_keys)
 
1026
        search_keys = index._find_ancestors([key1], 0, parent_map,
 
1027
                                            missing_keys)
1028
1028
        self.assertEqual({key1: (key2,), key2: (key3,)}, parent_map)
1029
1029
        self.assertEqual(set(), missing_keys)
1030
1030
        # all we know is that key3 wasn't present on the page we were reading
1031
1031
        # but if you look, the last key is key2 which comes before key3, so we
1032
1032
        # don't know whether key3 would land on this page or not.
1033
1033
        self.assertEqual(set([key3]), search_keys)
1034
 
        search_keys = index.get_ancestry(search_keys, 0, parent_map,
1035
 
                                         missing_keys)
 
1034
        search_keys = index._find_ancestors(search_keys, 0, parent_map,
 
1035
                                            missing_keys)
1036
1036
        # passing it back in, we are sure it is 'missing'
1037
1037
        self.assertEqual({key1: (key2,), key2: (key3,)}, parent_map)
1038
1038
        self.assertEqual(set([key3]), missing_keys)
1039
1039
        self.assertEqual(set([]), search_keys)
1040
1040
 
1041
 
    def test_get_ancestry_dont_search_known(self):
 
1041
    def test__find_ancestors_dont_search_known(self):
1042
1042
        key1 = ('key-1',)
1043
1043
        key2 = ('key-2',)
1044
1044
        key3 = ('key-3',)
1050
1050
        # We already know about key2, so we won't try to search for key3
1051
1051
        parent_map = {key2: (key3,)}
1052
1052
        missing_keys = set()
1053
 
        search_keys = index.get_ancestry([key1], 0, parent_map,
1054
 
                                         missing_keys)
 
1053
        search_keys = index._find_ancestors([key1], 0, parent_map,
 
1054
                                            missing_keys)
1055
1055
        self.assertEqual({key1: (key2,), key2: (key3,)}, parent_map)
1056
1056
        self.assertEqual(set(), missing_keys)
1057
1057
        self.assertEqual(set(), search_keys)
1058
1058
 
1059
 
    def test_get_ancestry_multiple_pages(self):
 
1059
    def test__find_ancestors_multiple_pages(self):
1060
1060
        # We need to use enough keys that we actually cause a split
1061
1061
        start_time = 1249671539
1062
1062
        email = "joebob@example.com"
1093
1093
        # parent of that key
1094
1094
        parent_map = {}
1095
1095
        missing_keys = set()
1096
 
        search_keys = index.get_ancestry([next_key], 0, parent_map,
1097
 
                                         missing_keys)
 
1096
        search_keys = index._find_ancestors([next_key], 0, parent_map,
 
1097
                                            missing_keys)
1098
1098
        self.assertEqual([min_l2_key, next_key], sorted(parent_map))
1099
1099
        self.assertEqual(set(), missing_keys)
1100
1100
        self.assertEqual(set([max_l1_key]), search_keys)
1101
1101
        parent_map = {}
1102
 
        search_keys = index.get_ancestry([max_l1_key], 0, parent_map,
1103
 
                                         missing_keys)
 
1102
        search_keys = index._find_ancestors([max_l1_key], 0, parent_map,
 
1103
                                            missing_keys)
1104
1104
        self.assertEqual(sorted(l1.keys), sorted(parent_map))
1105
1105
        self.assertEqual(set(), missing_keys)
1106
1106
        self.assertEqual(set(), search_keys)
1107
1107
 
1108
 
    def test_get_ancestry_empty_index(self):
 
1108
    def test__find_ancestors_empty_index(self):
1109
1109
        index = self.make_index(ref_lists=1, key_elements=1, nodes=[])
1110
1110
        parent_map = {}
1111
1111
        missing_keys = set()
1112
 
        search_keys = index.get_ancestry([('one',), ('two',)], 0, parent_map,
1113
 
                                         missing_keys)
 
1112
        search_keys = index._find_ancestors([('one',), ('two',)], 0, parent_map,
 
1113
                                            missing_keys)
1114
1114
        self.assertEqual(set(), search_keys)
1115
1115
        self.assertEqual({}, parent_map)
1116
1116
        self.assertEqual(set([('one',), ('two',)]), missing_keys)