/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: Martin Pool
  • Date: 2009-03-13 07:54:48 UTC
  • mfrom: (4144 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4189.
  • Revision ID: mbp@sourcefrog.net-20090313075448-jlz1t7baz7gzipqn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from bzrlib.tests import (
29
29
    TestCaseWithTransport,
30
 
    TestScenarioApplier,
31
 
    adapt_tests,
32
30
    condition_isinstance,
 
31
    multiply_tests,
33
32
    split_suite_by_condition,
34
33
    )
35
34
from bzrlib.transport import get_transport
39
38
    # parameterise the TestBTreeNodes tests
40
39
    node_tests, others = split_suite_by_condition(standard_tests,
41
40
        condition_isinstance(TestBTreeNodes))
42
 
    applier = TestScenarioApplier()
43
41
    import bzrlib._btree_serializer_py as py_module
44
 
    applier.scenarios = [('python', {'parse_btree': py_module})]
 
42
    scenarios = [('python', {'parse_btree': py_module})]
45
43
    if CompiledBtreeParserFeature.available():
46
44
        # Is there a way to do this that gets missing feature failures rather
47
45
        # than no indication to the user?
48
46
        import bzrlib._btree_serializer_c as c_module
49
 
        applier.scenarios.append(('C', {'parse_btree': c_module}))
50
 
    adapt_tests(node_tests, applier, others)
51
 
    return others
 
47
        scenarios.append(('C', {'parse_btree': c_module}))
 
48
    return multiply_tests(node_tests, scenarios, others)
52
49
 
53
50
 
54
51
class _CompiledBtreeParserFeature(tests.Feature):
869
866
            (index, ('name', 'fin2'), 'beta', ((), ))]),
870
867
            set(index.iter_entries_prefix([('name', None)])))
871
868
 
 
869
    # XXX: external_references tests are duplicated in test_index.  We
 
870
    # probably should have per_graph_index tests...
 
871
    def test_external_references_no_refs(self):
 
872
        index = self.make_index(ref_lists=0, nodes=[])
 
873
        self.assertRaises(ValueError, index.external_references, 0)
 
874
 
 
875
    def test_external_references_no_results(self):
 
876
        index = self.make_index(ref_lists=1, nodes=[
 
877
            (('key',), 'value', ([],))])
 
878
        self.assertEqual(set(), index.external_references(0))
 
879
 
 
880
    def test_external_references_missing_ref(self):
 
881
        missing_key = ('missing',)
 
882
        index = self.make_index(ref_lists=1, nodes=[
 
883
            (('key',), 'value', ([missing_key],))])
 
884
        self.assertEqual(set([missing_key]), index.external_references(0))
 
885
 
 
886
    def test_external_references_multiple_ref_lists(self):
 
887
        missing_key = ('missing',)
 
888
        index = self.make_index(ref_lists=2, nodes=[
 
889
            (('key',), 'value', ([], [missing_key]))])
 
890
        self.assertEqual(set([]), index.external_references(0))
 
891
        self.assertEqual(set([missing_key]), index.external_references(1))
 
892
 
 
893
    def test_external_references_two_records(self):
 
894
        index = self.make_index(ref_lists=1, nodes=[
 
895
            (('key-1',), 'value', ([('key-2',)],)),
 
896
            (('key-2',), 'value', ([],)),
 
897
            ])
 
898
        self.assertEqual(set([]), index.external_references(0))
 
899
 
872
900
 
873
901
class TestBTreeNodes(BTreeTestCase):
874
902