/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
1534.4.39 by Robert Collins
Basic BzrDir support.
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
# -*- coding: utf-8 -*-
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
4
#
1534.4.39 by Robert Collins
Basic BzrDir support.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
9
#
1534.4.39 by Robert Collins
Basic BzrDir support.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
14
#
1534.4.39 by Robert Collins
Basic BzrDir support.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
20
"""BzrDir implementation tests for bzr.
21
22
These test the conformance of all the bzrdir variations to the expected API.
23
Specific tests for individual formats are in the tests/test_bzrdir.py file 
24
rather than in tests/branch_implementations/*.py.
25
"""
26
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
27
from bzrlib.bzrdir import BzrDirFormat
1534.4.39 by Robert Collins
Basic BzrDir support.
28
from bzrlib.tests import (
29
                          adapt_modules,
30
                          default_transport,
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
31
                          TestCaseWithTransport,
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
32
                          TestScenarioApplier,
1534.4.39 by Robert Collins
Basic BzrDir support.
33
                          )
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
34
from bzrlib.transport.memory import MemoryServer
1534.4.39 by Robert Collins
Basic BzrDir support.
35
36
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
37
class BzrDirTestProviderAdapter(TestScenarioApplier):
38
    """A tool to generate a suite testing multiple bzrdir formats at once.
39
40
    This is done by copying the test once for each transport and injecting
41
    the transport_server, transport_readonly_server, and bzrdir_format
42
    classes into each copy. Each copy is also given a new id() to make it
43
    easy to identify.
44
    """
45
46
    def __init__(self, vfs_factory, transport_server, transport_readonly_server,
47
        formats):
48
        """Create an object to adapt tests.
49
50
        :param vfs_server: A factory to create a Transport Server which has
51
            all the VFS methods working, and is writable.
52
        """
53
        self._vfs_factory = vfs_factory
54
        self._transport_server = transport_server
55
        self._transport_readonly_server = transport_readonly_server
56
        self.scenarios = self.formats_to_scenarios(formats)
57
    
58
    def formats_to_scenarios(self, formats):
59
        """Transform the input formats to a list of scenarios.
60
61
        :param formats: A list of bzrdir_format objects.
62
        """
63
        result = []
64
        for format in formats:
65
            scenario = (format.__class__.__name__, {
66
                "vfs_transport_factory":self._vfs_factory,
67
                "transport_server":self._transport_server,
68
                "transport_readonly_server":self._transport_readonly_server,
69
                "bzrdir_format":format,
70
                })
71
            result.append(scenario)
72
        return result
73
74
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
75
class TestCaseWithBzrDir(TestCaseWithTransport):
76
77
    def setUp(self):
78
        super(TestCaseWithBzrDir, self).setUp()
79
        self.bzrdir = None
80
81
    def get_bzrdir(self):
82
        if self.bzrdir is None:
83
            self.bzrdir = self.make_bzrdir(None)
84
        return self.bzrdir
85
86
    def make_bzrdir(self, relpath, format=None):
3242.2.14 by Aaron Bentley
Update from review comments
87
        if format is None:
88
            format = self.bzrdir_format
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
89
        return super(TestCaseWithBzrDir, self).make_bzrdir(
3242.2.14 by Aaron Bentley
Update from review comments
90
            relpath, format=format)
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
91
92
3302.9.8 by Vincent Ladeuil
bzrlib.tests.bzrdir_implementations switched from test_suite() to load_tests().
93
def load_tests(basic_tests, module, loader):
94
    result = loader.suiteClass()
95
    # add the tests for this module
96
    result.addTests(basic_tests)
97
1534.4.39 by Robert Collins
Basic BzrDir support.
98
    test_bzrdir_implementations = [
99
        'bzrlib.tests.bzrdir_implementations.test_bzrdir',
100
        ]
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
101
    formats = BzrDirFormat.known_formats()
1534.4.39 by Robert Collins
Basic BzrDir support.
102
    adapter = BzrDirTestProviderAdapter(
103
        default_transport,
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
104
        None,
1534.4.39 by Robert Collins
Basic BzrDir support.
105
        # None here will cause a readonly decorator to be created
106
        # by the TestCaseWithTransport.get_readonly_transport method.
107
        None,
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
108
        formats)
3302.9.27 by Vincent Ladeuil
Fixed as per Ian's review.
109
    # add the tests for the sub modules
1534.4.39 by Robert Collins
Basic BzrDir support.
110
    adapt_modules(test_bzrdir_implementations, adapter, loader, result)
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
111
1752.2.53 by Andrew Bennetts
Add an XXX comment to the test suite hack.
112
    # This will always add the tests for smart server transport, regardless of
113
    # the --transport option the user specified to 'bzr selftest'.
3302.9.8 by Vincent Ladeuil
bzrlib.tests.bzrdir_implementations switched from test_suite() to load_tests().
114
    from bzrlib.smart.server import (
115
        SmartTCPServer_for_testing,
116
        ReadonlySmartTCPServer_for_testing,
117
        )
1752.2.87 by Andrew Bennetts
Make tests pass.
118
    from bzrlib.remote import RemoteBzrDirFormat
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
119
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
120
    # test the remote server behaviour using a MemoryTransport
3302.9.8 by Vincent Ladeuil
bzrlib.tests.bzrdir_implementations switched from test_suite() to load_tests().
121
    smart_server_suite = loader.suiteClass()
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
122
    adapt_to_smart_server = BzrDirTestProviderAdapter(
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
123
        MemoryServer,
124
        SmartTCPServer_for_testing,
125
        ReadonlySmartTCPServer_for_testing,
126
        [(RemoteBzrDirFormat())])
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
127
    adapt_modules(test_bzrdir_implementations,
1752.2.53 by Andrew Bennetts
Add an XXX comment to the test suite hack.
128
                  adapt_to_smart_server,
3302.9.8 by Vincent Ladeuil
bzrlib.tests.bzrdir_implementations switched from test_suite() to load_tests().
129
                  loader,
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
130
                  smart_server_suite)
131
    result.addTests(smart_server_suite)
132
1534.4.39 by Robert Collins
Basic BzrDir support.
133
    return result