1
# Copyright (C) 2009 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
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
17
"""Tests for Annotators."""
26
def load_tests(standard_tests, module, loader):
27
"""Parameterize tests for all versions of groupcompress."""
29
('python', {'module': _annotator_py}),
31
suite = loader.suiteClass()
32
if CompiledAnnotator.available():
33
from bzrlib import _annotator_pyx
34
scenarios.append(('C', {'module': _annotator_pyx}))
36
# the compiled module isn't available, so we add a failing test
37
class FailWithoutFeature(tests.TestCase):
39
self.requireFeature(CompiledAnnotator)
40
suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
41
result = tests.multiply_tests(standard_tests, scenarios, suite)
45
class _CompiledAnnotator(tests.Feature):
49
import bzrlib._annotator_pyx
54
def feature_name(self):
55
return 'bzrlib._annotator_pyx'
57
CompiledAnnotator = _CompiledAnnotator()
60
class TestAnnotator(tests.TestCaseWithMemoryTransport):
62
module = None # Set by load_tests
64
def make_single_text(self):
65
repo = self.make_repository('repo')
67
self.addCleanup(repo.unlock)
69
repo.start_write_group()
70
vf.add_lines(('f-id', 'a-id'), (), ['simple\n', 'content\n'])
71
repo.commit_write_group()
74
def test_annotate_missing(self):
75
vf = self.make_single_text()
76
ann = self.module.Annotator(vf)
77
self.assertRaises(errors.RevisionNotPresent,
78
ann.annotate, ('not', 'present'))
80
def test_annotate_simple(self):
81
vf = self.make_single_text()
82
ann = self.module.Annotator(vf)
83
f_key = ('f-id', 'a-id')
84
self.assertEqual(([(f_key,)]*2, ['simple\n', 'content\n']),