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

  • Committer: John Arbash Meinel
  • Date: 2007-04-28 15:04:17 UTC
  • mfrom: (2466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070428150417-trp3pi0pzd411pu4
[merge] bzr.dev 2466

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
rather than in tests/branch_implementations/*.py.
25
25
"""
26
26
 
 
27
from bzrlib import (
 
28
    errors,
 
29
    tests,
 
30
    )
27
31
from bzrlib.branch import (BranchFormat,
28
32
                           BranchTestProviderAdapter,
29
33
                           _legacy_formats,
30
34
                           )
31
 
from bzrlib.tests import (
32
 
                          adapt_modules,
33
 
                          default_transport,
34
 
                          TestLoader,
35
 
                          TestSuite,
36
 
                          )
 
35
from bzrlib.remote import RemoteBranchFormat, RemoteBzrDirFormat
 
36
from bzrlib.smart.server import (
 
37
    SmartTCPServer_for_testing,
 
38
    ReadonlySmartTCPServer_for_testing,
 
39
    )
 
40
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
 
41
from bzrlib.transport.memory import MemoryServer
 
42
 
 
43
 
 
44
class TestCaseWithBranch(TestCaseWithBzrDir):
 
45
    """This helper will be adapted for each branch_implementation test."""
 
46
 
 
47
    def setUp(self):
 
48
        super(TestCaseWithBranch, self).setUp()
 
49
        self.branch = None
 
50
 
 
51
    def get_branch(self):
 
52
        if self.branch is None:
 
53
            self.branch = self.make_branch('')
 
54
        return self.branch
 
55
 
 
56
    def make_branch(self, relpath, format=None):
 
57
        repo = self.make_repository(relpath, format=format)
 
58
        # fixme RBC 20060210 this isnt necessarily a fixable thing,
 
59
        # Skipped is the wrong exception to raise.
 
60
        try:
 
61
            return self.branch_format.initialize(repo.bzrdir)
 
62
        except errors.UninitializableFormat:
 
63
            raise tests.TestSkipped('Uninitializable branch format')
 
64
 
 
65
    def make_repository(self, relpath, shared=False, format=None):
 
66
        made_control = self.make_bzrdir(relpath, format=format)
 
67
        return made_control.create_repository(shared=shared)
 
68
 
 
69
    def create_tree_with_merge(self):
 
70
        """Create a branch with a simple ancestry.
 
71
 
 
72
        The graph should look like:
 
73
            digraph H {
 
74
                "rev-1" -> "rev-2" -> "rev-3";
 
75
                "rev-1" -> "rev-1.1.1" -> "rev-3";
 
76
            }
 
77
 
 
78
        Or in ASCII:
 
79
            1
 
80
            |\
 
81
            2 1.1.1
 
82
            |/
 
83
            3
 
84
        """
 
85
        tree = self.make_branch_and_memory_tree('tree')
 
86
        tree.lock_write()
 
87
        try:
 
88
            tree.add('')
 
89
            tree.commit('first', rev_id='rev-1')
 
90
            tree.commit('second', rev_id='rev-1.1.1')
 
91
            # Uncommit that last commit and switch to the other line
 
92
            tree.branch.set_last_revision_info(1, 'rev-1')
 
93
            tree.set_parent_ids(['rev-1'])
 
94
            tree.commit('alt-second', rev_id='rev-2')
 
95
            tree.set_parent_ids(['rev-2', 'rev-1.1.1'])
 
96
            tree.commit('third', rev_id='rev-3')
 
97
        finally:
 
98
            tree.unlock()
 
99
 
 
100
        return tree
37
101
 
38
102
 
39
103
def test_suite():
40
 
    result = TestSuite()
 
104
    result = tests.TestSuite()
41
105
    test_branch_implementations = [
42
106
        'bzrlib.tests.branch_implementations.test_bound_sftp',
43
107
        'bzrlib.tests.branch_implementations.test_branch',
44
108
        'bzrlib.tests.branch_implementations.test_break_lock',
45
109
        'bzrlib.tests.branch_implementations.test_create_checkout',
46
110
        'bzrlib.tests.branch_implementations.test_commit',
 
111
        'bzrlib.tests.branch_implementations.test_get_revision_id_to_revno_map',
47
112
        'bzrlib.tests.branch_implementations.test_hooks',
48
113
        'bzrlib.tests.branch_implementations.test_http',
49
114
        'bzrlib.tests.branch_implementations.test_last_revision_info',
53
118
        'bzrlib.tests.branch_implementations.test_pull',
54
119
        'bzrlib.tests.branch_implementations.test_push',
55
120
        'bzrlib.tests.branch_implementations.test_revision_history',
 
121
        'bzrlib.tests.branch_implementations.test_revision_id_to_revno',
56
122
        'bzrlib.tests.branch_implementations.test_tags',
57
123
        'bzrlib.tests.branch_implementations.test_uncommit',
58
124
        'bzrlib.tests.branch_implementations.test_update',
62
128
    combinations = [(format, format._matchingbzrdir) for format in 
63
129
         BranchFormat._formats.values() + _legacy_formats]
64
130
    adapter = BranchTestProviderAdapter(
65
 
        default_transport,
 
131
        # None here will cause the default vfs transport server to be used.
 
132
        None,
66
133
        # None here will cause a readonly decorator to be created
67
134
        # by the TestCaseWithTransport.get_readonly_transport method.
68
135
        None,
69
136
        combinations)
70
 
    loader = TestLoader()
71
 
    adapt_modules(test_branch_implementations, adapter, loader, result)
 
137
    loader = tests.TestLoader()
 
138
    tests.adapt_modules(test_branch_implementations, adapter, loader, result)
 
139
 
 
140
    adapt_to_smart_server = BranchTestProviderAdapter(
 
141
        SmartTCPServer_for_testing,
 
142
        ReadonlySmartTCPServer_for_testing,
 
143
        [(RemoteBranchFormat(), RemoteBzrDirFormat())],
 
144
        MemoryServer
 
145
        )
 
146
    tests.adapt_modules(test_branch_implementations,
 
147
                        adapt_to_smart_server,
 
148
                        loader,
 
149
                        result)
 
150
 
72
151
    return result