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)
47
scenarios.append(('C', {'parse_btree': c_module}))
48
return multiply_tests(node_tests, scenarios, others)
54
51
class _CompiledBtreeParserFeature(tests.Feature):
869
866
(index, ('name', 'fin2'), 'beta', ((), ))]),
870
867
set(index.iter_entries_prefix([('name', None)])))
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)
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))
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))
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))
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', ([],)),
898
self.assertEqual(set([]), index.external_references(0))
873
901
class TestBTreeNodes(BTreeTestCase):