/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2255.7.9 by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite
1
# Copyright (C) 2006, 2007 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
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
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
25
import bzrlib.errors as errors
26
from bzrlib.transport import get_transport
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
27
from bzrlib.tests import (
28
                          adapt_modules,
29
                          default_transport,
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
30
                          TestScenarioApplier,
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
31
                          )
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
32
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
33
from bzrlib.workingtree import (WorkingTreeFormat,
34
                                _legacy_formats,
35
                                )
36
37
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
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)
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
51
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
52
    def formats_to_scenarios(self, formats):
53
        """Transform the input formats to a list of scenarios.
54
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
55
        :param formats: A list [workingtree_format].
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
56
        """
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
57
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
58
        result = []
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
59
        for workingtree_format in formats:
60
            result.append(self.create_scenario(workingtree_format))
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
61
        return result
62
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
63
    def create_scenario(self, workingtree_format):
3363.1.6 by Aaron Bentley
Add docs
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
        """
3363.1.1 by Aaron Bentley
Refactor intertree scenario creation
71
        scenario_options = {
72
            "transport_server": self._transport_server,
73
            "transport_readonly_server": self._transport_readonly_server,
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
74
            "bzrdir_format": workingtree_format._matchingbzrdir,
3363.1.1 by Aaron Bentley
Refactor intertree scenario creation
75
            "workingtree_format": workingtree_format,
76
            }
77
        return workingtree_format.__class__.__name__, scenario_options
78
2553.2.10 by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too.
79
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
80
class TestCaseWithWorkingTree(TestCaseWithBzrDir):
81
82
    def make_branch_and_tree(self, relpath, format=None):
83
        made_control = self.make_bzrdir(relpath, format=format)
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
84
        made_control.create_repository()
85
        made_control.create_branch()
86
        return self.workingtree_format.initialize(made_control)
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
87
88
3302.9.16 by Vincent Ladeuil
bzrlib.tests.workingtree_implementations switched from
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
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
94
    test_workingtree_implementations = [
2100.3.8 by Aaron Bentley
Add add_reference
95
        'bzrlib.tests.workingtree_implementations.test_add_reference',
2255.7.10 by John Arbash Meinel
Handle the case when we are adding a file to an empty directory.
96
        'bzrlib.tests.workingtree_implementations.test_add',
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
97
        'bzrlib.tests.workingtree_implementations.test_basis_inventory',
2255.2.72 by John Arbash Meinel
Add some tests for WorkingTree.basis_tree()
98
        'bzrlib.tests.workingtree_implementations.test_basis_tree',
1687.1.9 by Robert Collins
Teach WorkingTree about break-lock.
99
        'bzrlib.tests.workingtree_implementations.test_break_lock',
1852.9.6 by Robert Collins
Merge the change from Tree.compare to Tree.changes_from.
100
        'bzrlib.tests.workingtree_implementations.test_changes_from',
1666.1.18 by Robert Collins
Add a progress bar during commit operations.
101
        'bzrlib.tests.workingtree_implementations.test_commit',
1711.4.30 by John Arbash Meinel
Don't peak under the covers, and test all working tree implementations for executable success (suggested by Robert Collins)
102
        'bzrlib.tests.workingtree_implementations.test_executable',
1986.5.3 by Robert Collins
New method ``WorkingTree.flush()`` which will write the current memory
103
        'bzrlib.tests.workingtree_implementations.test_flush',
2405.3.1 by John Arbash Meinel
Add some tests for get_file_mtime, and clean up others.
104
        'bzrlib.tests.workingtree_implementations.test_get_file_mtime',
1773.2.1 by Robert Collins
Teach all trees about unknowns, conflicts and get_parent_ids.
105
        'bzrlib.tests.workingtree_implementations.test_get_parent_ids',
2338.4.2 by Marien Zwart
Move the workingtree-related inventory tests to a separate file.
106
        'bzrlib.tests.workingtree_implementations.test_inv',
1534.5.5 by Robert Collins
Move is_control_file into WorkingTree.is_control_filename and test.
107
        'bzrlib.tests.workingtree_implementations.test_is_control_filename',
1713.2.1 by Robert Collins
Some tests for WorkingTree.is_ignored so it can be refactored with confidence.
108
        'bzrlib.tests.workingtree_implementations.test_is_ignored',
1711.8.5 by John Arbash Meinel
Move the new locking tests into their own files, and move the helper functions into a test helper.
109
        'bzrlib.tests.workingtree_implementations.test_locking',
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
110
        'bzrlib.tests.workingtree_implementations.test_merge_from_branch',
1908.11.3 by Robert Collins
Merge bzr.dev
111
        'bzrlib.tests.workingtree_implementations.test_mkdir',
2255.2.137 by John Arbash Meinel
Move the WorkingTree.move() tests into their own module
112
        'bzrlib.tests.workingtree_implementations.test_move',
2255.2.195 by Robert Collins
Fix set_reference_revision on dirstate format trees.
113
        'bzrlib.tests.workingtree_implementations.test_nested_specifics',
1908.5.3 by Robert Collins
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.
114
        'bzrlib.tests.workingtree_implementations.test_parents',
2255.2.100 by Robert Collins
Create a paths2ids api to replace find_ids_across_trees, with tests.
115
        'bzrlib.tests.workingtree_implementations.test_paths2ids',
1563.1.4 by Robert Collins
Fix 'bzr pull' on metadir trees.
116
        'bzrlib.tests.workingtree_implementations.test_pull',
1986.1.2 by Robert Collins
Various changes to allow non-workingtree specific tests to run entirely
117
        'bzrlib.tests.workingtree_implementations.test_put_file',
2201.1.1 by John Arbash Meinel
Fix bug #76299 by ignoring write errors during readonly hashcache write.
118
        'bzrlib.tests.workingtree_implementations.test_readonly',
1986.5.3 by Robert Collins
New method ``WorkingTree.flush()`` which will write the current memory
119
        'bzrlib.tests.workingtree_implementations.test_read_working_inventory',
2292.1.30 by Marius Kruger
* Minor text fixes.
120
        'bzrlib.tests.workingtree_implementations.test_remove',
2255.7.9 by John Arbash Meinel
Add more tests for WorkingTree.move() and a similar suite
121
        'bzrlib.tests.workingtree_implementations.test_rename_one',
1908.11.2 by Robert Collins
Implement WorkingTree interface conformance tests for
122
        'bzrlib.tests.workingtree_implementations.test_revision_tree',
1986.5.2 by Robert Collins
``WorkingTree.set_root_id(None)`` is now deprecated. Please
123
        'bzrlib.tests.workingtree_implementations.test_set_root_id',
2255.2.62 by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly
124
        'bzrlib.tests.workingtree_implementations.test_smart_add',
2598.5.7 by Aaron Bentley
Updates from review
125
        'bzrlib.tests.workingtree_implementations.test_uncommit',
1988.2.1 by Robert Collins
WorkingTree has a new api ``unversion`` which allow the unversioning of
126
        'bzrlib.tests.workingtree_implementations.test_unversion',
1852.15.7 by Robert Collins
Start testing behaviour of unknowns in WorkingTree.walkdirs.
127
        'bzrlib.tests.workingtree_implementations.test_walkdirs',
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
128
        'bzrlib.tests.workingtree_implementations.test_workingtree',
129
        ]
3302.9.16 by Vincent Ladeuil
bzrlib.tests.workingtree_implementations switched from
130
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
131
    adapter = WorkingTreeTestProviderAdapter(
132
        default_transport,
133
        # None here will cause a readonly decorator to be created
134
        # by the TestCaseWithTransport.get_readonly_transport method.
135
        None,
3543.1.1 by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and
136
        WorkingTreeFormat._formats.values() + _legacy_formats)
3302.9.16 by Vincent Ladeuil
bzrlib.tests.workingtree_implementations switched from
137
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
138
    # add the tests for the sub modules
1534.4.46 by Robert Collins
Nearly complete .bzr/checkout splitout.
139
    adapt_modules(test_workingtree_implementations, adapter, loader, result)
140
    return result