/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/workingtree_implementations/__init__.py

  • Committer: Aaron Bentley
  • Date: 2008-10-16 21:27:10 UTC
  • mfrom: (0.15.26 unshelve)
  • mto: (0.16.74 shelf-ui)
  • mto: This revision was merged to the branch mainline in revision 3820.
  • Revision ID: aaron@aaronbentley.com-20081016212710-h9av3nhk76dvmsv5
Merge with unshelve

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
"""WorkingTree implementation tests for bzr.
 
19
 
 
20
These test the conformance of all the workingtre variations to the expected API.
 
21
Specific tests for individual formats are in the tests/test_workingtree file 
 
22
rather than in tests/workingtree_implementations/*.py.
 
23
"""
 
24
 
 
25
import bzrlib.errors as errors
 
26
from bzrlib.transport import get_transport
 
27
from bzrlib.tests import (
 
28
                          adapt_modules,
 
29
                          default_transport,
 
30
                          TestScenarioApplier,
 
31
                          )
 
32
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
 
33
from bzrlib.workingtree import (WorkingTreeFormat,
 
34
                                _legacy_formats,
 
35
                                )
 
36
 
 
37
 
 
38
class WorkingTreeTestProviderAdapter(TestScenarioApplier):
 
39
    """A tool to generate a suite testing multiple workingtree formats at once.
 
40
 
 
41
    This is done by copying the test once for each transport and injecting
 
42
    the transport_server, transport_readonly_server, and workingtree_format
 
43
    classes into each copy. Each copy is also given a new id() to make it
 
44
    easy to identify.
 
45
    """
 
46
 
 
47
    def __init__(self, transport_server, transport_readonly_server, formats):
 
48
        self._transport_server = transport_server
 
49
        self._transport_readonly_server = transport_readonly_server
 
50
        self.scenarios = self.formats_to_scenarios(formats)
 
51
 
 
52
    def formats_to_scenarios(self, formats):
 
53
        """Transform the input formats to a list of scenarios.
 
54
 
 
55
        :param formats: A list [workingtree_format].
 
56
        """
 
57
 
 
58
        result = []
 
59
        for workingtree_format in formats:
 
60
            result.append(self.create_scenario(workingtree_format))
 
61
        return result
 
62
 
 
63
    def create_scenario(self, workingtree_format):
 
64
        """Create a scenario for the specified converter
 
65
 
 
66
        :param workingtree_format: The particular workingtree format to test.
 
67
        :param bzrdir_format: The bzrdir format to test.
 
68
        :return: a (name, options) tuple, where options is a dict of values
 
69
            to be used as members of the TestCase.
 
70
        """
 
71
        scenario_options = {
 
72
            "transport_server": self._transport_server,
 
73
            "transport_readonly_server": self._transport_readonly_server,
 
74
            "bzrdir_format": workingtree_format._matchingbzrdir,
 
75
            "workingtree_format": workingtree_format,
 
76
            }
 
77
        return workingtree_format.__class__.__name__, scenario_options
 
78
 
 
79
 
 
80
class TestCaseWithWorkingTree(TestCaseWithBzrDir):
 
81
 
 
82
    def make_branch_and_tree(self, relpath, format=None):
 
83
        made_control = self.make_bzrdir(relpath, format=format)
 
84
        made_control.create_repository()
 
85
        made_control.create_branch()
 
86
        return self.workingtree_format.initialize(made_control)
 
87
 
 
88
 
 
89
def load_tests(basic_tests, module, loader):
 
90
    result = loader.suiteClass()
 
91
    # add the tests for this module
 
92
    result.addTests(basic_tests)
 
93
 
 
94
    test_workingtree_implementations = [
 
95
        'bzrlib.tests.workingtree_implementations.test_add_reference',
 
96
        'bzrlib.tests.workingtree_implementations.test_add',
 
97
        'bzrlib.tests.workingtree_implementations.test_basis_inventory',
 
98
        'bzrlib.tests.workingtree_implementations.test_basis_tree',
 
99
        'bzrlib.tests.workingtree_implementations.test_break_lock',
 
100
        'bzrlib.tests.workingtree_implementations.test_changes_from',
 
101
        'bzrlib.tests.workingtree_implementations.test_commit',
 
102
        'bzrlib.tests.workingtree_implementations.test_executable',
 
103
        'bzrlib.tests.workingtree_implementations.test_flush',
 
104
        'bzrlib.tests.workingtree_implementations.test_get_file_with_stat',
 
105
        'bzrlib.tests.workingtree_implementations.test_get_file_mtime',
 
106
        'bzrlib.tests.workingtree_implementations.test_get_parent_ids',
 
107
        'bzrlib.tests.workingtree_implementations.test_inv',
 
108
        'bzrlib.tests.workingtree_implementations.test_is_control_filename',
 
109
        'bzrlib.tests.workingtree_implementations.test_is_ignored',
 
110
        'bzrlib.tests.workingtree_implementations.test_locking',
 
111
        'bzrlib.tests.workingtree_implementations.test_merge_from_branch',
 
112
        'bzrlib.tests.workingtree_implementations.test_mkdir',
 
113
        'bzrlib.tests.workingtree_implementations.test_move',
 
114
        'bzrlib.tests.workingtree_implementations.test_nested_specifics',
 
115
        'bzrlib.tests.workingtree_implementations.test_parents',
 
116
        'bzrlib.tests.workingtree_implementations.test_paths2ids',
 
117
        'bzrlib.tests.workingtree_implementations.test_pull',
 
118
        'bzrlib.tests.workingtree_implementations.test_put_file',
 
119
        'bzrlib.tests.workingtree_implementations.test_readonly',
 
120
        'bzrlib.tests.workingtree_implementations.test_read_working_inventory',
 
121
        'bzrlib.tests.workingtree_implementations.test_remove',
 
122
        'bzrlib.tests.workingtree_implementations.test_rename_one',
 
123
        'bzrlib.tests.workingtree_implementations.test_revision_tree',
 
124
        'bzrlib.tests.workingtree_implementations.test_set_root_id',
 
125
        'bzrlib.tests.workingtree_implementations.test_smart_add',
 
126
        'bzrlib.tests.workingtree_implementations.test_uncommit',
 
127
        'bzrlib.tests.workingtree_implementations.test_unversion',
 
128
        'bzrlib.tests.workingtree_implementations.test_walkdirs',
 
129
        'bzrlib.tests.workingtree_implementations.test_workingtree',
 
130
        ]
 
131
 
 
132
    adapter = WorkingTreeTestProviderAdapter(
 
133
        default_transport,
 
134
        # None here will cause a readonly decorator to be created
 
135
        # by the TestCaseWithTransport.get_readonly_transport method.
 
136
        None,
 
137
        WorkingTreeFormat._formats.values() + _legacy_formats)
 
138
 
 
139
    # add the tests for the sub modules
 
140
    adapt_modules(test_workingtree_implementations, adapter, loader, result)
 
141
    return result