/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Copyright (C) 2006 Canonical Ltd
# Authors: Robert Collins <robert.collins@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


"""RevisionStore implemnetation tests for bzr.

These test the conformance of all the revision store implementations to the 
expected API including generally applicable corner cases.
Specific tests for individual cases are in the tests/test_revisionstore.py file 
rather than in tests/revisionstore_implementations/*.py.
"""

from bzrlib.tests import (
                          adapt_modules,
                          default_transport,
                          TestLoader,
                          TestScenarioApplier,
                          TestSuite,
                          )


class RevisionStoreTestProviderAdapter(TestScenarioApplier):
    """A tool to generate a suite testing multiple repository stores.

    This is done by copying the test once for each repository store
    and injecting the transport_server, transport_readonly_server,
    and revision-store-factory into each copy.
    Each copy is also given a new id() to make it easy to identify.
    """

    def __init__(self, transport_server, transport_readonly_server, factories):
        self._transport_server = transport_server
        self._transport_readonly_server = transport_readonly_server
        self.scenarios = self.factories_to_scenarios(factories)
    
    def factories_to_scenarios(self, factories):
        """Transform the input factories to a list of scenarios.

        :param factories: A list of factories.
        """
        result = []
        for factory in factories:
            scenario = (factory, {
                "transport_server":self._transport_server,
                "transport_readonly_server":self._transport_readonly_server,
                "store_factory":factory,
                })
            result.append(scenario)
        return result

    @staticmethod
    def default_test_list():
        """Generate the default list of revision store permutations to test."""
        from bzrlib.store.revision.text import TextRevisionStoreTestFactory
        from bzrlib.store.revision.knit import KnitRevisionStoreFactory
        result = []
        # test the fallback InterVersionedFile from weave to annotated knits
        result.append(TextRevisionStoreTestFactory())
        result.append(KnitRevisionStoreFactory())
        return result


def test_suite():
    result = TestSuite()
    test_revisionstore_implementations = [
        'bzrlib.tests.revisionstore_implementations.test_all',
        ]
    adapter = RevisionStoreTestProviderAdapter(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        RevisionStoreTestProviderAdapter.default_test_list()
        )
    loader = TestLoader()
    adapt_modules(test_revisionstore_implementations, adapter, loader, result)
    return result