bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2009, 2011, 2016 Canonical Ltd
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
4585.1.3
by Jelmer Vernooij
Add last_revision test. |
17 |
|
18 |
"""Tests specific to Branch implementations that use foreign VCS'es."""
|
|
19 |
||
6734.1.11
by Jelmer Vernooij
Move UnstackableBranchFormat. |
20 |
from breezy.branch import ( |
21 |
UnstackableBranchFormat, |
|
22 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
23 |
from breezy.errors import ( |
5699.3.1
by Jelmer Vernooij
Require foreign branch formats to raise IncompatibleFormat for bzr dirs. |
24 |
IncompatibleFormat, |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
25 |
)
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
26 |
from breezy.revision import ( |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
27 |
NULL_REVISION, |
28 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
29 |
from breezy.tests import ( |
4585.1.8
by Jelmer Vernooij
Make branch formats provide a factory for particular situations. |
30 |
TestCaseWithTransport, |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
31 |
)
|
6819.1.1
by Jelmer Vernooij
Some smaller fixes. |
32 |
from breezy.sixish import ( |
33 |
text_type, |
|
34 |
)
|
|
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
35 |
|
36 |
||
37 |
class ForeignBranchFactory(object): |
|
38 |
"""Factory of branches for ForeignBranchTests.""" |
|
39 |
||
4585.1.8
by Jelmer Vernooij
Make branch formats provide a factory for particular situations. |
40 |
def make_empty_branch(self, transport): |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
41 |
"""Create an empty branch with no commits in it.""" |
42 |
raise NotImplementedError(self.make_empty_branch) |
|
43 |
||
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
44 |
def make_branch(self, transport): |
45 |
"""Create *some* branch, may be empty or not.""" |
|
46 |
return self.make_empty_branch(transport) |
|
47 |
||
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
48 |
|
4585.1.8
by Jelmer Vernooij
Make branch formats provide a factory for particular situations. |
49 |
class ForeignBranchTests(TestCaseWithTransport): |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
50 |
"""Basic tests for foreign branch implementations. |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
51 |
|
7195.5.1
by Martin
Fix remaining whitespace lint in codebase |
52 |
These tests mainly make sure that the implementation covers the required
|
53 |
bits of the API and returns reasonable values.
|
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
54 |
"""
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
55 |
branch_factory = None # Set to an instance of ForeignBranchFactory by scenario |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
56 |
|
4585.1.8
by Jelmer Vernooij
Make branch formats provide a factory for particular situations. |
57 |
def make_empty_branch(self): |
58 |
return self.branch_factory.make_empty_branch(self.get_transport()) |
|
59 |
||
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
60 |
def make_branch(self): |
61 |
return self.branch_factory.make_branch(self.get_transport()) |
|
62 |
||
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
63 |
def test_set_parent(self): |
64 |
"""Test that setting the parent works.""" |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
65 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
66 |
branch.set_parent("foobar") |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
67 |
|
68 |
def test_set_push_location(self): |
|
69 |
"""Test that setting the push location works.""" |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
70 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
71 |
branch.set_push_location("http://bar/bloe") |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
72 |
|
73 |
def test_repr_type(self): |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
74 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
75 |
self.assertIsInstance(repr(branch), str) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
76 |
|
77 |
def test_get_parent(self): |
|
78 |
"""Test that getting the parent location works, and returns None.""" |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
79 |
# TODO: Allow this to be non-None when foreign branches add support
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
80 |
# for storing this URL.
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
81 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
82 |
self.assertIs(None, branch.get_parent()) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
83 |
|
84 |
def test_get_push_location(self): |
|
85 |
"""Test that getting the push location works, and returns None.""" |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
86 |
# TODO: Allow this to be non-None when foreign branches add support
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
87 |
# for storing this URL.
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
88 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
89 |
self.assertIs(None, branch.get_push_location()) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
90 |
|
91 |
def test_attributes(self): |
|
92 |
"""Check that various required attributes are present.""" |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
93 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
94 |
self.assertIsNot(None, getattr(branch, "repository", None)) |
95 |
self.assertIsNot(None, getattr(branch, "mapping", None)) |
|
96 |
self.assertIsNot(None, getattr(branch, "_format", None)) |
|
97 |
self.assertIsNot(None, getattr(branch, "base", None)) |
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
98 |
|
99 |
def test__get_nick(self): |
|
100 |
"""Make sure _get_nick is implemented and returns a string.""" |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
101 |
branch = self.make_branch() |
6819.1.1
by Jelmer Vernooij
Some smaller fixes. |
102 |
self.assertIsInstance(branch._get_nick(local=False), text_type) |
103 |
self.assertIsInstance(branch._get_nick(local=True), text_type) |
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
104 |
|
105 |
def test_null_revid_revno(self): |
|
106 |
"""null: should return revno 0.""" |
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
107 |
branch = self.make_branch() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
108 |
self.assertEqual(0, branch.revision_id_to_revno(NULL_REVISION)) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
109 |
|
110 |
def test_get_stacked_on_url(self): |
|
111 |
"""Test that get_stacked_on_url() behaves as expected. |
|
112 |
||
113 |
Inter-Format stacking doesn't work yet, so all foreign implementations
|
|
114 |
should raise UnstackableBranchFormat at the moment.
|
|
115 |
"""
|
|
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
116 |
branch = self.make_branch() |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
117 |
self.assertRaises(UnstackableBranchFormat, |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
118 |
branch.get_stacked_on_url) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
119 |
|
4585.1.2
by Jelmer Vernooij
Add physical lock status test. |
120 |
def test_get_physical_lock_status(self): |
4585.1.9
by Jelmer Vernooij
Distinguish between "some branch" and empty branches. |
121 |
branch = self.make_branch() |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
122 |
self.assertFalse(branch.get_physical_lock_status()) |
123 |
||
124 |
def test_last_revision_empty_branch(self): |
|
4585.1.8
by Jelmer Vernooij
Make branch formats provide a factory for particular situations. |
125 |
branch = self.make_empty_branch() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
126 |
self.assertEqual(NULL_REVISION, branch.last_revision()) |
127 |
self.assertEqual(0, branch.revno()) |
|
128 |
self.assertEqual((0, NULL_REVISION), branch.last_revision_info()) |
|
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
129 |
|
130 |
||
5699.3.1
by Jelmer Vernooij
Require foreign branch formats to raise IncompatibleFormat for bzr dirs. |
131 |
class ForeignBranchFormatTests(TestCaseWithTransport): |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
132 |
"""Basic tests for foreign branch format objects.""" |
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
133 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
134 |
branch_format = None # Set to a BranchFormat instance by adapter |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
135 |
|
136 |
def test_initialize(self): |
|
4585.1.2
by Jelmer Vernooij
Add physical lock status test. |
137 |
"""Test this format is not initializable. |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
138 |
|
4585.1.3
by Jelmer Vernooij
Add last_revision test. |
139 |
Remote branches may be initializable on their own, but none currently
|
140 |
support living in .bzr/branch.
|
|
4585.1.2
by Jelmer Vernooij
Add physical lock status test. |
141 |
"""
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
142 |
bzrdir = self.make_controldir('dir') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
143 |
self.assertRaises(IncompatibleFormat, |
144 |
self.branch_format.initialize, bzrdir) |
|
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
145 |
|
146 |
def test_get_format_description_type(self): |
|
4585.1.7
by Jelmer Vernooij
Use scenarios and adapters. |
147 |
self.assertIsInstance(self.branch_format.get_format_description(), str) |
4585.1.1
by Jelmer Vernooij
Add foreign branch tests. |
148 |
|
149 |
def test_network_name(self): |
|
6973.6.3
by Jelmer Vernooij
More fixes. |
150 |
self.assertIsInstance(self.branch_format.network_name(), bytes) |