/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2006 Canonical Ltd
1563.2.21 by Robert Collins
Smoke test for RevisionStore factories creating revision stores.
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19
"""RevisionStore implemnetation tests for bzr.
20
21
These test the conformance of all the revision store implementations to the 
22
expected API including generally applicable corner cases.
23
Specific tests for individual cases are in the tests/test_revisionstore.py file 
24
rather than in tests/revisionstore_implementations/*.py.
25
"""
26
27
from bzrlib.tests import (
28
                          adapt_modules,
29
                          default_transport,
30
                          TestLoader,
2553.2.9 by Robert Collins
And overhaul RevisionStoreTestProviderAdapter too.
31
                          TestScenarioApplier,
1563.2.21 by Robert Collins
Smoke test for RevisionStore factories creating revision stores.
32
                          TestSuite,
33
                          )
34
35
2553.2.9 by Robert Collins
And overhaul RevisionStoreTestProviderAdapter too.
36
class RevisionStoreTestProviderAdapter(TestScenarioApplier):
37
    """A tool to generate a suite testing multiple repository stores.
38
39
    This is done by copying the test once for each repository store
40
    and injecting the transport_server, transport_readonly_server,
41
    and revision-store-factory into each copy.
42
    Each copy is also given a new id() to make it easy to identify.
43
    """
44
45
    def __init__(self, transport_server, transport_readonly_server, factories):
46
        self._transport_server = transport_server
47
        self._transport_readonly_server = transport_readonly_server
48
        self.scenarios = self.factories_to_scenarios(factories)
49
    
50
    def factories_to_scenarios(self, factories):
51
        """Transform the input factories to a list of scenarios.
52
53
        :param factories: A list of factories.
54
        """
55
        result = []
56
        for factory in factories:
57
            scenario = (factory, {
58
                "transport_server":self._transport_server,
59
                "transport_readonly_server":self._transport_readonly_server,
60
                "store_factory":factory,
61
                })
62
            result.append(scenario)
63
        return result
64
65
    @staticmethod
66
    def default_test_list():
67
        """Generate the default list of revision store permutations to test."""
68
        from bzrlib.store.revision.text import TextRevisionStoreTestFactory
69
        from bzrlib.store.revision.knit import KnitRevisionStoreFactory
70
        result = []
71
        # test the fallback InterVersionedFile from weave to annotated knits
72
        result.append(TextRevisionStoreTestFactory())
73
        result.append(KnitRevisionStoreFactory())
74
        return result
75
76
1563.2.21 by Robert Collins
Smoke test for RevisionStore factories creating revision stores.
77
def test_suite():
78
    result = TestSuite()
79
    test_revisionstore_implementations = [
80
        'bzrlib.tests.revisionstore_implementations.test_all',
81
        ]
82
    adapter = RevisionStoreTestProviderAdapter(
83
        default_transport,
84
        # None here will cause a readonly decorator to be created
85
        # by the TestCaseWithTransport.get_readonly_transport method.
86
        None,
87
        RevisionStoreTestProviderAdapter.default_test_list()
88
        )
89
    loader = TestLoader()
90
    adapt_modules(test_revisionstore_implementations, adapter, loader, result)
91
    return result