~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_index.py

  • Committer: Martin Pool
  • Date: 2008-12-16 07:56:29 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081216075629-zhgjzxgoh32453tu
Choose the UIFactory class depending on the terminal capabilities

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for indices."""
18
18
 
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
 
 
956
925
 
957
926
class TestCombinedGraphIndex(TestCaseWithMemoryTransport):
958
927
 
1078
1047
        self.assertEqual(set([(index1, ('name', ), 'data', ((('ref', ), ), )),
1079
1048
            (index2, ('ref', ), 'refdata', ((), ))]),
1080
1049
            set(index.iter_entries([('name', ), ('ref', )])))
1081
 
 
 
1050
 
1082
1051
    def test_iter_all_keys_dup_entry(self):
1083
1052
        index1 = self.make_index('1', 1, nodes=[
1084
1053
            (('name', ), 'data', ([('ref', )], )),
1089
1058
        self.assertEqual(set([(index1, ('name', ), 'data', ((('ref',),),)),
1090
1059
            (index1, ('ref', ), 'refdata', ((), ))]),
1091
1060
            set(index.iter_entries([('name', ), ('ref', )])))
1092
 
 
 
1061
 
1093
1062
    def test_iter_missing_entry_empty(self):
1094
1063
        index = CombinedGraphIndex([])
1095
1064
        self.assertEqual([], list(index.iter_entries([('a', )])))
1104
1073
        index2 = self.make_index('2')
1105
1074
        index = CombinedGraphIndex([index1, index2])
1106
1075
        self.assertEqual([], list(index.iter_entries([('a', )])))
1107
 
 
 
1076
 
1108
1077
    def test_iter_entry_present_one_index_only(self):
1109
1078
        index1 = self.make_index('1', nodes=[(('key', ), '', ())])
1110
1079
        index2 = self.make_index('2', nodes=[])