/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,
1534.4.39 by Robert Collins
Basic BzrDir support.
32
                          TestLoader,
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
33
                          TestScenarioApplier,
1534.4.39 by Robert Collins
Basic BzrDir support.
34
                          TestSuite,
35
                          )
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
36
from bzrlib.transport.memory import MemoryServer
1534.4.39 by Robert Collins
Basic BzrDir support.
37
38
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
39
class BzrDirTestProviderAdapter(TestScenarioApplier):
40
    """A tool to generate a suite testing multiple bzrdir formats at once.
41
42
    This is done by copying the test once for each transport and injecting
43
    the transport_server, transport_readonly_server, and bzrdir_format
44
    classes into each copy. Each copy is also given a new id() to make it
45
    easy to identify.
46
    """
47
48
    def __init__(self, vfs_factory, transport_server, transport_readonly_server,
49
        formats):
50
        """Create an object to adapt tests.
51
52
        :param vfs_server: A factory to create a Transport Server which has
53
            all the VFS methods working, and is writable.
54
        """
55
        self._vfs_factory = vfs_factory
56
        self._transport_server = transport_server
57
        self._transport_readonly_server = transport_readonly_server
58
        self.scenarios = self.formats_to_scenarios(formats)
59
    
60
    def formats_to_scenarios(self, formats):
61
        """Transform the input formats to a list of scenarios.
62
63
        :param formats: A list of bzrdir_format objects.
64
        """
65
        result = []
66
        for format in formats:
67
            scenario = (format.__class__.__name__, {
68
                "vfs_transport_factory":self._vfs_factory,
69
                "transport_server":self._transport_server,
70
                "transport_readonly_server":self._transport_readonly_server,
71
                "bzrdir_format":format,
72
                })
73
            result.append(scenario)
74
        return result
75
76
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
77
class TestCaseWithBzrDir(TestCaseWithTransport):
78
79
    def setUp(self):
80
        super(TestCaseWithBzrDir, self).setUp()
81
        self.bzrdir = None
82
83
    def get_bzrdir(self):
84
        if self.bzrdir is None:
85
            self.bzrdir = self.make_bzrdir(None)
86
        return self.bzrdir
87
88
    def make_bzrdir(self, relpath, format=None):
89
        return super(TestCaseWithBzrDir, self).make_bzrdir(
90
            relpath, format=self.bzrdir_format)
91
92
1534.4.39 by Robert Collins
Basic BzrDir support.
93
def test_suite():
94
    result = TestSuite()
95
    test_bzrdir_implementations = [
96
        'bzrlib.tests.bzrdir_implementations.test_bzrdir',
97
        ]
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
98
    formats = BzrDirFormat.known_formats()
1534.4.39 by Robert Collins
Basic BzrDir support.
99
    adapter = BzrDirTestProviderAdapter(
100
        default_transport,
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
101
        None,
1534.4.39 by Robert Collins
Basic BzrDir support.
102
        # None here will cause a readonly decorator to be created
103
        # by the TestCaseWithTransport.get_readonly_transport method.
104
        None,
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
105
        formats)
1534.4.39 by Robert Collins
Basic BzrDir support.
106
    loader = TestLoader()
107
    adapt_modules(test_bzrdir_implementations, adapter, loader, result)
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
108
1752.2.53 by Andrew Bennetts
Add an XXX comment to the test suite hack.
109
    # This will always add the tests for smart server transport, regardless of
110
    # the --transport option the user specified to 'bzr selftest'.
2018.5.31 by Robert Collins
Make RemoteBzrDir tests use a real smart transport connection to a read only server instance for read-only tests.
111
    from bzrlib.smart.server import SmartTCPServer_for_testing, ReadonlySmartTCPServer_for_testing
1752.2.87 by Andrew Bennetts
Make tests pass.
112
    from bzrlib.remote import RemoteBzrDirFormat
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
113
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
114
    # test the remote server behaviour using a MemoryTransport
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
115
    smart_server_suite = TestSuite()
116
    adapt_to_smart_server = BzrDirTestProviderAdapter(
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
117
        MemoryServer,
118
        SmartTCPServer_for_testing,
119
        ReadonlySmartTCPServer_for_testing,
120
        [(RemoteBzrDirFormat())])
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
121
    adapt_modules(test_bzrdir_implementations,
1752.2.53 by Andrew Bennetts
Add an XXX comment to the test suite hack.
122
                  adapt_to_smart_server,
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
123
                  TestLoader(),
124
                  smart_server_suite)
125
    result.addTests(smart_server_suite)
126
1534.4.39 by Robert Collins
Basic BzrDir support.
127
    return result