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) 2006-2013, 2016 Canonical Ltd
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
16 |
|
17 |
"""Tests for remote bzrdir/branch/repo/etc
|
|
18 |
||
19 |
These are proxy objects which act on remote objects by sending messages
|
|
20 |
through a smart client. The proxies are to be created when attempting to open
|
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
21 |
the object given a transport that supports smartserver rpc operations.
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
22 |
|
23 |
These tests correspond to tests.test_smart, which exercises the server side.
|
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
24 |
"""
|
25 |
||
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
26 |
import base64 |
|
3211.5.2
by Robert Collins
Change RemoteRepository.get_parent_map to use bz2 not gzip for compression. |
27 |
import bz2 |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
28 |
from io import BytesIO |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
29 |
import tarfile |
|
6280.9.4
by Jelmer Vernooij
use zlib instead. |
30 |
import zlib |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
31 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
32 |
from .. import ( |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
33 |
bencode, |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
34 |
branch, |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
35 |
config, |
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
36 |
controldir, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
37 |
errors, |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
38 |
repository, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
39 |
tests, |
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
40 |
transport, |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
41 |
treebuilder, |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
42 |
)
|
43 |
from ..branch import Branch |
|
44 |
from ..bzr import ( |
|
45 |
bzrdir, |
|
46 |
inventory, |
|
47 |
inventory_delta, |
|
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
48 |
remote, |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
49 |
versionedfile, |
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
50 |
vf_search, |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
51 |
)
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
52 |
from ..bzr.bzrdir import ( |
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
53 |
BzrDir, |
54 |
BzrDirFormat, |
|
|
6695.5.1
by Jelmer Vernooij
Move bzr format registration to breezy.bzr. |
55 |
)
|
56 |
from ..bzr import ( |
|
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
57 |
RemoteBzrProber, |
58 |
)
|
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
59 |
from ..bzr.chk_serializer import chk_bencode_serializer |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
60 |
from ..bzr.remote import ( |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
61 |
RemoteBranch, |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
62 |
RemoteBranchFormat, |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
63 |
RemoteBzrDir, |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
64 |
RemoteBzrDirFormat, |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
65 |
RemoteRepository, |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
66 |
RemoteRepositoryFormat, |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
67 |
)
|
|
6670.4.5
by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr. |
68 |
from ..bzr import groupcompress_repo, knitpack_repo |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
69 |
from ..revision import ( |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
70 |
NULL_REVISION, |
71 |
Revision, |
|
72 |
)
|
|
|
6670.4.16
by Jelmer Vernooij
Move smart to breezy.bzr. |
73 |
from ..bzr.smart import medium, request |
74 |
from ..bzr.smart.client import _SmartClient |
|
75 |
from ..bzr.smart.repository import ( |
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
76 |
SmartServerRepositoryGetParentMap, |
77 |
SmartServerRepositoryGetStream_1_19, |
|
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
78 |
_stream_to_byte_stream, |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
79 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
80 |
from . import ( |
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
81 |
test_server, |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
82 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
83 |
from .scenarios import load_tests_apply_scenarios |
84 |
from ..transport.memory import MemoryTransport |
|
85 |
from ..transport.remote import ( |
|
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
86 |
RemoteTransport, |
87 |
RemoteSSHTransport, |
|
88 |
RemoteTCPTransport, |
|
|
5579.3.1
by Jelmer Vernooij
Remove unused imports. |
89 |
)
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
90 |
|
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
91 |
|
92 |
load_tests = load_tests_apply_scenarios |
|
93 |
||
94 |
||
95 |
class BasicRemoteObjectTests(tests.TestCaseWithTransport): |
|
96 |
||
97 |
scenarios = [ |
|
|
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
98 |
('HPSS-v2', |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
99 |
{'transport_server': |
100 |
test_server.SmartTCPServer_for_testing_v2_only}), |
|
|
4104.4.2
by Robert Collins
Fix test_source for 1.13 landing. |
101 |
('HPSS-v3', |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
102 |
{'transport_server': test_server.SmartTCPServer_for_testing})] |
103 |
||
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
104 |
def setUp(self): |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
105 |
super(BasicRemoteObjectTests, self).setUp() |
106 |
self.transport = self.get_transport() |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
107 |
# make a branch that can be opened over the smart transport
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
108 |
self.local_wt = BzrDir.create_standalone_workingtree('.') |
|
4986.2.1
by Martin Pool
Remove tearDown in tests in favor of addCleanup |
109 |
self.addCleanup(self.transport.disconnect) |
|
2018.5.171
by Andrew Bennetts
Disconnect RemoteTransports in some tests to avoid tripping up test_strace with leftover threads from previous tests. |
110 |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
111 |
def test_create_remote_bzrdir(self): |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
112 |
b = remote.RemoteBzrDir(self.transport, RemoteBzrDirFormat()) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
113 |
self.assertIsInstance(b, BzrDir) |
114 |
||
115 |
def test_open_remote_branch(self): |
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
116 |
# open a standalone branch in the working directory
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
117 |
b = remote.RemoteBzrDir(self.transport, RemoteBzrDirFormat()) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
118 |
branch = b.open_branch() |
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
119 |
self.assertIsInstance(branch, Branch) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
120 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
121 |
def test_remote_repository(self): |
122 |
b = BzrDir.open_from_transport(self.transport) |
|
123 |
repo = b.open_repository() |
|
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
124 |
revid = u'\xc823123123'.encode('utf8') |
|
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
125 |
self.assertFalse(repo.has_revision(revid)) |
126 |
self.local_wt.commit(message='test commit', rev_id=revid) |
|
127 |
self.assertTrue(repo.has_revision(revid)) |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
128 |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
129 |
def test_find_correct_format(self): |
|
2018.5.20
by Andrew Bennetts
Move bzrlib/transport/smart/_smart.py to bzrlib/transport/remote.py and rename SmartTransport to RemoteTransport (Robert Collins, Andrew Bennetts) |
130 |
"""Should open a RemoteBzrDir over a RemoteTransport""" |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
131 |
fmt = BzrDirFormat.find_format(self.transport) |
|
7413.6.1
by Jelmer Vernooij
Add an optional priority field for probers. |
132 |
self.assertIn(RemoteBzrProber, controldir.ControlDirFormat._probers) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
133 |
self.assertIsInstance(fmt, RemoteBzrDirFormat) |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
134 |
|
135 |
def test_open_detected_smart_format(self): |
|
136 |
fmt = BzrDirFormat.find_format(self.transport) |
|
137 |
d = fmt.open(self.transport) |
|
138 |
self.assertIsInstance(d, BzrDir) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
139 |
|
|
2477.1.1
by Martin Pool
Add RemoteBranch repr |
140 |
def test_remote_branch_repr(self): |
141 |
b = BzrDir.open_from_transport(self.transport).open_branch() |
|
142 |
self.assertStartsWith(str(b), 'RemoteBranch(') |
|
143 |
||
|
4964.2.1
by Martin Pool
Add RemoteBzrDir repr |
144 |
def test_remote_bzrdir_repr(self): |
145 |
b = BzrDir.open_from_transport(self.transport) |
|
146 |
self.assertStartsWith(str(b), 'RemoteBzrDir(') |
|
147 |
||
|
4103.2.2
by Andrew Bennetts
Fix RemoteBranchFormat.supports_stacking() |
148 |
def test_remote_branch_format_supports_stacking(self): |
149 |
t = self.transport |
|
150 |
self.make_branch('unstackable', format='pack-0.92') |
|
151 |
b = BzrDir.open_from_transport(t.clone('unstackable')).open_branch() |
|
152 |
self.assertFalse(b._format.supports_stacking()) |
|
153 |
self.make_branch('stackable', format='1.9') |
|
154 |
b = BzrDir.open_from_transport(t.clone('stackable')).open_branch() |
|
155 |
self.assertTrue(b._format.supports_stacking()) |
|
156 |
||
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
157 |
def test_remote_repo_format_supports_external_references(self): |
158 |
t = self.transport |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
159 |
bd = self.make_controldir('unstackable', format='pack-0.92') |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
160 |
r = bd.create_repository() |
161 |
self.assertFalse(r._format.supports_external_lookups) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
162 |
r = BzrDir.open_from_transport( |
163 |
t.clone('unstackable')).open_repository() |
|
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
164 |
self.assertFalse(r._format.supports_external_lookups) |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
165 |
bd = self.make_controldir('stackable', format='1.9') |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
166 |
r = bd.create_repository() |
167 |
self.assertTrue(r._format.supports_external_lookups) |
|
168 |
r = BzrDir.open_from_transport(t.clone('stackable')).open_repository() |
|
169 |
self.assertTrue(r._format.supports_external_lookups) |
|
170 |
||
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
171 |
def test_remote_branch_set_append_revisions_only(self): |
172 |
# Make a format 1.9 branch, which supports append_revisions_only
|
|
173 |
branch = self.make_branch('branch', format='1.9') |
|
174 |
branch.set_append_revisions_only(True) |
|
|
6372.4.2
by Jelmer Vernooij
Fix remaining tests. |
175 |
config = branch.get_config_stack() |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
176 |
self.assertEqual( |
|
6372.4.1
by Jelmer Vernooij
Convert 'append_revisions_only' over to config stacks. |
177 |
True, config.get('append_revisions_only')) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
178 |
branch.set_append_revisions_only(False) |
|
6372.4.2
by Jelmer Vernooij
Fix remaining tests. |
179 |
config = branch.get_config_stack() |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
180 |
self.assertEqual( |
|
6372.4.1
by Jelmer Vernooij
Convert 'append_revisions_only' over to config stacks. |
181 |
False, config.get('append_revisions_only')) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
182 |
|
183 |
def test_remote_branch_set_append_revisions_only_upgrade_reqd(self): |
|
184 |
branch = self.make_branch('branch', format='knit') |
|
185 |
self.assertRaises( |
|
|
4301.3.3
by Andrew Bennetts
Move check onto base Branch class, and add a supports_set_append_revisions_only method to BranchFormat, as suggested by Robert. |
186 |
errors.UpgradeRequired, branch.set_append_revisions_only, True) |
|
4301.3.1
by Andrew Bennetts
Implement RemoteBranch.set_append_revisions_only. |
187 |
|
|
3691.2.4
by Martin Pool
Add FakeRemoteTransport to clarify test_remote |
188 |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
189 |
class FakeProtocol(object): |
190 |
"""Lookalike SmartClientRequestProtocolOne allowing body reading tests.""" |
|
191 |
||
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
192 |
def __init__(self, body, fake_client): |
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
193 |
self.body = body |
194 |
self._body_buffer = None |
|
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
195 |
self._fake_client = fake_client |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
196 |
|
197 |
def read_body_bytes(self, count=-1): |
|
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
198 |
if self._body_buffer is None: |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
199 |
self._body_buffer = BytesIO(self.body) |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
200 |
bytes = self._body_buffer.read(count) |
201 |
if self._body_buffer.tell() == len(self._body_buffer.getvalue()): |
|
202 |
self._fake_client.expecting_body = False |
|
203 |
return bytes |
|
204 |
||
205 |
def cancel_read_body(self): |
|
206 |
self._fake_client.expecting_body = False |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
207 |
|
|
2535.4.2
by Andrew Bennetts
Nasty hackery to make stream_knit_data_for_revisions response use streaming. |
208 |
def read_streamed_body(self): |
209 |
return self.body |
|
210 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
211 |
|
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
212 |
class FakeClient(_SmartClient): |
213 |
"""Lookalike for _SmartClient allowing testing.""" |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
214 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
215 |
def __init__(self, fake_medium_base='fake base'): |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
216 |
"""Create a FakeClient.""" |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
217 |
self.responses = [] |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
218 |
self._calls = [] |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
219 |
self.expecting_body = False |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
220 |
# if non-None, this is the list of expected calls, with only the
|
221 |
# method name and arguments included. the body might be hard to
|
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
222 |
# compute so is not included. If a call is None, that call can
|
223 |
# be anything.
|
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
224 |
self._expected_calls = None |
|
3431.3.2
by Andrew Bennetts
Remove 'base' from _SmartClient entirely, now that the medium has it. |
225 |
_SmartClient.__init__(self, FakeMedium(self._calls, fake_medium_base)) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
226 |
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
227 |
def add_expected_call(self, call_name, call_args, response_type, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
228 |
response_args, response_body=None): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
229 |
if self._expected_calls is None: |
230 |
self._expected_calls = [] |
|
231 |
self._expected_calls.append((call_name, call_args)) |
|
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
232 |
self.responses.append((response_type, response_args, response_body)) |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
233 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
234 |
def add_success_response(self, *args): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
235 |
self.responses.append((b'success', args, None)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
236 |
|
237 |
def add_success_response_with_body(self, body, *args): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
238 |
self.responses.append((b'success', args, body)) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
239 |
if self._expected_calls is not None: |
240 |
self._expected_calls.append(None) |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
241 |
|
242 |
def add_error_response(self, *args): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
243 |
self.responses.append((b'error', args)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
244 |
|
245 |
def add_unknown_method_response(self, verb): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
246 |
self.responses.append((b'unknown', verb)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
247 |
|
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
248 |
def finished_test(self): |
249 |
if self._expected_calls: |
|
250 |
raise AssertionError("%r finished but was still expecting %r" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
251 |
% (self, self._expected_calls[0])) |
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
252 |
|
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
253 |
def _get_next_response(self): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
254 |
try: |
255 |
response_tuple = self.responses.pop(0) |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
256 |
except IndexError: |
257 |
raise AssertionError("%r didn't expect any more calls" % (self,)) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
258 |
if response_tuple[0] == b'unknown': |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
259 |
raise errors.UnknownSmartMethod(response_tuple[1]) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
260 |
elif response_tuple[0] == b'error': |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
261 |
raise errors.ErrorFromSmartServer(response_tuple[1]) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
262 |
return response_tuple |
263 |
||
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
264 |
def _check_call(self, method, args): |
265 |
if self._expected_calls is None: |
|
266 |
# the test should be updated to say what it expects
|
|
267 |
return
|
|
268 |
try: |
|
269 |
next_call = self._expected_calls.pop(0) |
|
270 |
except IndexError: |
|
271 |
raise AssertionError("%r didn't expect any more calls " |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
272 |
"but got %r%r" |
273 |
% (self, method, args,)) |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
274 |
if next_call is None: |
275 |
return
|
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
276 |
if method != next_call[0] or args != next_call[1]: |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
277 |
raise AssertionError( |
278 |
"%r expected %r%r but got %r%r" % |
|
279 |
(self, next_call[0], next_call[1], method, args,)) |
|
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
280 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
281 |
def call(self, method, *args): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
282 |
self._check_call(method, args) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
283 |
self._calls.append(('call', method, args)) |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
284 |
return self._get_next_response()[1] |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
285 |
|
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
286 |
def call_expecting_body(self, method, *args): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
287 |
self._check_call(method, args) |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
288 |
self._calls.append(('call_expecting_body', method, args)) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
289 |
result = self._get_next_response() |
|
2535.3.68
by Andrew Bennetts
Backwards compatibility for new smart method. |
290 |
self.expecting_body = True |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
291 |
return result[1], FakeProtocol(result[2], self) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
292 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
293 |
def call_with_body_bytes(self, method, args, body): |
294 |
self._check_call(method, args) |
|
295 |
self._calls.append(('call_with_body_bytes', method, args, body)) |
|
296 |
result = self._get_next_response() |
|
297 |
return result[1], FakeProtocol(result[2], self) |
|
298 |
||
|
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
299 |
def call_with_body_bytes_expecting_body(self, method, args, body): |
|
3691.2.7
by Martin Pool
FakeClient can know what calls to expect |
300 |
self._check_call(method, args) |
|
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
301 |
self._calls.append(('call_with_body_bytes_expecting_body', method, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
302 |
args, body)) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
303 |
result = self._get_next_response() |
|
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
304 |
self.expecting_body = True |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
305 |
return result[1], FakeProtocol(result[2], self) |
|
3184.1.10
by Robert Collins
Change the smart server verb for Repository.stream_revisions_chunked to use SearchResults as the request mechanism for downloads. |
306 |
|
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
307 |
def call_with_body_stream(self, args, stream): |
308 |
# Explicitly consume the stream before checking for an error, because
|
|
309 |
# that's what happens a real medium.
|
|
310 |
stream = list(stream) |
|
311 |
self._check_call(args[0], args[1:]) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
312 |
self._calls.append( |
313 |
('call_with_body_stream', args[0], args[1:], stream)) |
|
|
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
314 |
result = self._get_next_response() |
|
4144.3.3
by Andrew Bennetts
Tweaks based on review from Robert. |
315 |
# The second value returned from call_with_body_stream is supposed to
|
316 |
# be a response_handler object, but so far no tests depend on that.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
317 |
response_handler = None |
|
4144.3.3
by Andrew Bennetts
Tweaks based on review from Robert. |
318 |
return result[1], response_handler |
|
3842.3.9
by Andrew Bennetts
Backing up the stream so that we can fallback correctly. |
319 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
320 |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
321 |
class FakeMedium(medium.SmartClientMedium): |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
322 |
|
|
3431.3.1
by Andrew Bennetts
First rough cut of a fix for bug #230550, by adding .base to SmartClientMedia rather than relying on other objects to track this accurately while reusing client media. |
323 |
def __init__(self, client_calls, base): |
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
324 |
medium.SmartClientMedium.__init__(self, base) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
325 |
self._client_calls = client_calls |
|
3213.1.1
by Andrew Bennetts
Recover (by reconnecting) if the server turns out not to understand the new requests in 1.2 that send bodies. |
326 |
|
327 |
def disconnect(self): |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
328 |
self._client_calls.append(('disconnect medium',)) |
|
3104.4.2
by Andrew Bennetts
All tests passing. |
329 |
|
330 |
||
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
331 |
class TestVfsHas(tests.TestCase): |
332 |
||
333 |
def test_unicode_path(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
334 |
client = FakeClient('/') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
335 |
client.add_success_response(b'yes',) |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
336 |
transport = RemoteTransport('bzr://localhost/', _client=client) |
|
7065.3.6
by Jelmer Vernooij
Fix some more tests. |
337 |
filename = u'/hell\u00d8' |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
338 |
result = transport.has(filename) |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
339 |
self.assertEqual( |
|
7065.3.6
by Jelmer Vernooij
Fix some more tests. |
340 |
[('call', b'has', (filename.encode('utf-8'),))], |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
341 |
client._calls) |
342 |
self.assertTrue(result) |
|
343 |
||
344 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
345 |
class TestRemote(tests.TestCaseWithMemoryTransport): |
|
4032.1.1
by John Arbash Meinel
Merge the removal of all trailing whitespace, and resolve conflicts. |
346 |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
347 |
def get_branch_format(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
348 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
349 |
return reference_bzrdir_format.get_branch_format() |
350 |
||
|
4053.1.2
by Robert Collins
Actually make this branch work. |
351 |
def get_repo_format(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
352 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
353 |
return reference_bzrdir_format.repository_format |
354 |
||
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
355 |
def assertFinished(self, fake_client): |
356 |
"""Assert that all of a FakeClient's expected calls have occurred.""" |
|
|
4523.3.2
by Andrew Bennetts
Adjust according to Robert's review. |
357 |
fake_client.finished_test() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
358 |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
359 |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
360 |
class Test_ClientMedium_remote_path_from_transport(tests.TestCase): |
361 |
"""Tests for the behaviour of client_medium.remote_path_from_transport.""" |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
362 |
|
363 |
def assertRemotePath(self, expected, client_base, transport_base): |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
364 |
"""Assert that the result of |
365 |
SmartClientMedium.remote_path_from_transport is the expected value for
|
|
366 |
a given client_base and transport_base.
|
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
367 |
"""
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
368 |
client_medium = medium.SmartClientMedium(client_base) |
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
369 |
t = transport.get_transport(transport_base) |
370 |
result = client_medium.remote_path_from_transport(t) |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
371 |
self.assertEqual(expected, result) |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
372 |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
373 |
def test_remote_path_from_transport(self): |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
374 |
"""SmartClientMedium.remote_path_from_transport calculates a URL for |
375 |
the given transport relative to the root of the client base URL.
|
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
376 |
"""
|
377 |
self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz') |
|
378 |
self.assertRemotePath( |
|
379 |
'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz') |
|
380 |
||
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
381 |
def assertRemotePathHTTP(self, expected, transport_base, relpath): |
382 |
"""Assert that the result of |
|
383 |
HttpTransportBase.remote_path_from_transport is the expected value for
|
|
384 |
a given transport_base and relpath of that transport. (Note that
|
|
385 |
HttpTransportBase is a subclass of SmartClientMedium)
|
|
386 |
"""
|
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
387 |
base_transport = transport.get_transport(transport_base) |
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
388 |
client_medium = base_transport.get_smart_medium() |
389 |
cloned_transport = base_transport.clone(relpath) |
|
390 |
result = client_medium.remote_path_from_transport(cloned_transport) |
|
391 |
self.assertEqual(expected, result) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
392 |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
393 |
def test_remote_path_from_transport_http(self): |
394 |
"""Remote paths for HTTP transports are calculated differently to other |
|
395 |
transports. They are just relative to the client base, not the root
|
|
396 |
directory of the host.
|
|
397 |
"""
|
|
398 |
for scheme in ['http:', 'https:', 'bzr+http:', 'bzr+https:']: |
|
|
3431.3.11
by Andrew Bennetts
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient. |
399 |
self.assertRemotePathHTTP( |
400 |
'../xyz/', scheme + '//host/path', '../xyz/') |
|
401 |
self.assertRemotePathHTTP( |
|
402 |
'xyz/', scheme + '//host/path', 'xyz/') |
|
|
3313.3.3
by Andrew Bennetts
Add tests for _SmartClient.remote_path_for_transport. |
403 |
|
404 |
||
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
405 |
class Test_ClientMedium_remote_is_at_least(tests.TestCase): |
406 |
"""Tests for the behaviour of client_medium.remote_is_at_least.""" |
|
407 |
||
408 |
def test_initially_unlimited(self): |
|
409 |
"""A fresh medium assumes that the remote side supports all |
|
410 |
versions.
|
|
411 |
"""
|
|
412 |
client_medium = medium.SmartClientMedium('dummy base') |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
413 |
self.assertFalse(client_medium._is_remote_before((99, 99))) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
414 |
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
415 |
def test__remember_remote_is_before(self): |
416 |
"""Calling _remember_remote_is_before ratchets down the known remote |
|
417 |
version.
|
|
418 |
"""
|
|
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
419 |
client_medium = medium.SmartClientMedium('dummy base') |
420 |
# Mark the remote side as being less than 1.6. The remote side may
|
|
421 |
# still be 1.5.
|
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
422 |
client_medium._remember_remote_is_before((1, 6)) |
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
423 |
self.assertTrue(client_medium._is_remote_before((1, 6))) |
424 |
self.assertFalse(client_medium._is_remote_before((1, 5))) |
|
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
425 |
# Calling _remember_remote_is_before again with a lower value works.
|
426 |
client_medium._remember_remote_is_before((1, 5)) |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
427 |
self.assertTrue(client_medium._is_remote_before((1, 5))) |
|
4797.49.4
by Andrew Bennetts
Expand test a little further, and use consistent terminology in its comments. |
428 |
# If you call _remember_remote_is_before with a higher value it logs a
|
429 |
# warning, and continues to remember the lower value.
|
|
|
4797.49.1
by Andrew Bennetts
First, fix _remember_remote_is_before to never raise AssertionError for what is a very minor bug. |
430 |
self.assertNotContainsRe(self.get_log(), '_remember_remote_is_before') |
431 |
client_medium._remember_remote_is_before((1, 9)) |
|
432 |
self.assertContainsRe(self.get_log(), '_remember_remote_is_before') |
|
|
4797.49.4
by Andrew Bennetts
Expand test a little further, and use consistent terminology in its comments. |
433 |
self.assertTrue(client_medium._is_remote_before((1, 5))) |
|
3453.4.1
by Andrew Bennetts
Better infrastructure on SmartClientMedium for tracking the remote version. |
434 |
|
435 |
||
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
436 |
class TestBzrDirCloningMetaDir(TestRemote): |
437 |
||
438 |
def test_backwards_compat(self): |
|
439 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
440 |
a_dir = self.make_controldir('.') |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
441 |
self.reset_smart_call_log() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
442 |
verb = b'BzrDir.cloning_metadir' |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
443 |
self.disable_verb(verb) |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
444 |
a_dir.cloning_metadir() |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
445 |
call_count = len([call for call in self.hpss_calls if |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
446 |
call.call.method == verb]) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
447 |
self.assertEqual(1, call_count) |
448 |
||
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
449 |
def test_branch_reference(self): |
450 |
transport = self.get_transport('quack') |
|
451 |
referenced = self.make_branch('referenced') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
452 |
expected = referenced.controldir.cloning_metadir() |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
453 |
client = FakeClient(transport.base) |
454 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
455 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
456 |
b'error', (b'BranchReference',)), |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
457 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
458 |
b'BzrDir.open_branchV3', (b'quack/',), |
|
7067.1.1
by Jelmer Vernooij
Fix some remote references issues. |
459 |
b'success', (b'ref', self.get_url('referenced').encode('utf-8'))), |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
460 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
461 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
462 |
result = a_controldir.cloning_metadir() |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
463 |
# We should have got a control dir matching the referenced branch.
|
464 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
465 |
self.assertEqual(expected._repository_format, |
466 |
result._repository_format) |
|
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
467 |
self.assertEqual(expected._branch_format, result._branch_format) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
468 |
self.assertFinished(client) |
|
4160.2.9
by Andrew Bennetts
Fix BzrDir.cloning_metadir RPC to fail on branch references, and make |
469 |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
470 |
def test_current_server(self): |
471 |
transport = self.get_transport('.') |
|
472 |
transport = transport.clone('quack') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
473 |
self.make_controldir('quack') |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
474 |
client = FakeClient(transport.base) |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
475 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
476 |
control_name = reference_bzrdir_format.network_name() |
477 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
478 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
479 |
b'success', (control_name, b'', (b'branch', b''))), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
480 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
481 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
482 |
result = a_controldir.cloning_metadir() |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
483 |
# We should have got a reference control dir with default branch and
|
484 |
# repository formats.
|
|
485 |
# This pokes a little, just to be sure.
|
|
486 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
|
4070.2.8
by Robert Collins
Really test the current BzrDir.cloning_metadir contract. |
487 |
self.assertEqual(None, result._repository_format) |
488 |
self.assertEqual(None, result._branch_format) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
489 |
self.assertFinished(client) |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
490 |
|
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
491 |
def test_unknown(self): |
492 |
transport = self.get_transport('quack') |
|
493 |
referenced = self.make_branch('referenced') |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
494 |
referenced.controldir.cloning_metadir() |
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
495 |
client = FakeClient(transport.base) |
496 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
497 |
b'BzrDir.cloning_metadir', (b'quack/', b'False'), |
498 |
b'success', (b'unknown', b'unknown', (b'branch', b''))), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
499 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
500 |
_client=client) |
501 |
self.assertRaises(errors.UnknownFormatError, |
|
502 |
a_controldir.cloning_metadir) |
|
|
6305.4.1
by Jelmer Vernooij
Print sensible error message when remote format is unknown. |
503 |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
504 |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
505 |
class TestBzrDirCheckoutMetaDir(TestRemote): |
506 |
||
507 |
def test__get_checkout_format(self): |
|
508 |
transport = MemoryTransport() |
|
509 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
510 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
511 |
control_name = reference_bzrdir_format.network_name() |
512 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
513 |
b'BzrDir.checkout_metadir', (b'quack/', ), |
514 |
b'success', (control_name, b'', b'')) |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
515 |
transport.mkdir('quack') |
516 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
517 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
518 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
519 |
result = a_controldir.checkout_metadir() |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
520 |
# We should have got a reference control dir with default branch and
|
521 |
# repository formats.
|
|
522 |
self.assertEqual(bzrdir.BzrDirMetaFormat1, type(result)) |
|
523 |
self.assertEqual(None, result._repository_format) |
|
524 |
self.assertEqual(None, result._branch_format) |
|
525 |
self.assertFinished(client) |
|
526 |
||
527 |
def test_unknown_format(self): |
|
528 |
transport = MemoryTransport() |
|
529 |
client = FakeClient(transport.base) |
|
530 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
531 |
b'BzrDir.checkout_metadir', (b'quack/',), |
532 |
b'success', (b'dontknow', b'', b'')) |
|
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
533 |
transport.mkdir('quack') |
534 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
535 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
536 |
_client=client) |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
537 |
self.assertRaises(errors.UnknownFormatError, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
538 |
a_controldir.checkout_metadir) |
|
6305.5.10
by Jelmer Vernooij
Move to BzrDir.checkout_metadir. |
539 |
self.assertFinished(client) |
540 |
||
541 |
||
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
542 |
class TestBzrDirGetBranches(TestRemote): |
543 |
||
544 |
def test_get_branches(self): |
|
545 |
transport = MemoryTransport() |
|
546 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
547 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
6436.3.2
by Jelmer Vernooij
Add HPSS call for BzrDir.get_branches. |
548 |
branch_name = reference_bzrdir_format.get_branch_format().network_name() |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
549 |
client.add_success_response_with_body( |
550 |
bencode.bencode({ |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
551 |
b"foo": (b"branch", branch_name), |
552 |
b"": (b"branch", branch_name)}), b"success") |
|
553 |
client.add_success_response( |
|
554 |
b'ok', b'', b'no', b'no', b'no', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
555 |
reference_bzrdir_format.repository_format.network_name()) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
556 |
client.add_error_response(b'NotStacked') |
557 |
client.add_success_response( |
|
558 |
b'ok', b'', b'no', b'no', b'no', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
559 |
reference_bzrdir_format.repository_format.network_name()) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
560 |
client.add_error_response(b'NotStacked') |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
561 |
transport.mkdir('quack') |
562 |
transport = transport.clone('quack') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
563 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
564 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
565 |
result = a_controldir.get_branches() |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
566 |
self.assertEqual({"", "foo"}, set(result.keys())) |
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
567 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
568 |
[('call_expecting_body', b'BzrDir.get_branches', (b'quack/',)), |
569 |
('call', b'BzrDir.find_repositoryV3', (b'quack/', )), |
|
570 |
('call', b'Branch.get_stacked_on_url', (b'quack/', )), |
|
571 |
('call', b'BzrDir.find_repositoryV3', (b'quack/', )), |
|
572 |
('call', b'Branch.get_stacked_on_url', (b'quack/', ))], |
|
|
6436.3.1
by Jelmer Vernooij
Add remote get_branches call. |
573 |
client._calls) |
574 |
||
575 |
||
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
576 |
class TestBzrDirDestroyBranch(TestRemote): |
577 |
||
578 |
def test_destroy_default(self): |
|
579 |
transport = self.get_transport('quack') |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
580 |
self.make_branch('referenced') |
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
581 |
client = FakeClient(transport.base) |
582 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
583 |
b'BzrDir.destroy_branch', (b'quack/', ), |
584 |
b'success', (b'ok',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
585 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
586 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
587 |
a_controldir.destroy_branch() |
|
6266.4.1
by Jelmer Vernooij
HPSS call 'BzrDir.destroy_branch'. |
588 |
self.assertFinished(client) |
589 |
||
590 |
||
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
591 |
class TestBzrDirHasWorkingTree(TestRemote): |
592 |
||
593 |
def test_has_workingtree(self): |
|
594 |
transport = self.get_transport('quack') |
|
595 |
client = FakeClient(transport.base) |
|
596 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
597 |
b'BzrDir.has_workingtree', (b'quack/',), |
598 |
b'success', (b'yes',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
599 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
600 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
601 |
self.assertTrue(a_controldir.has_workingtree()) |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
602 |
self.assertFinished(client) |
603 |
||
604 |
def test_no_workingtree(self): |
|
605 |
transport = self.get_transport('quack') |
|
606 |
client = FakeClient(transport.base) |
|
607 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
608 |
b'BzrDir.has_workingtree', (b'quack/',), |
609 |
b'success', (b'no',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
610 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
611 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
612 |
self.assertFalse(a_controldir.has_workingtree()) |
|
6266.3.1
by Jelmer Vernooij
Add HPSS call for BzrDir.has_workingtree. |
613 |
self.assertFinished(client) |
614 |
||
615 |
||
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
616 |
class TestBzrDirDestroyRepository(TestRemote): |
617 |
||
618 |
def test_destroy_repository(self): |
|
619 |
transport = self.get_transport('quack') |
|
620 |
client = FakeClient(transport.base) |
|
621 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
622 |
b'BzrDir.destroy_repository', (b'quack/',), |
623 |
b'success', (b'ok',)), |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
624 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
625 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
626 |
a_controldir.destroy_repository() |
|
6266.2.1
by Jelmer Vernooij
New HPSS call BzrDir.destroy_repository. |
627 |
self.assertFinished(client) |
628 |
||
629 |
||
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
630 |
class TestBzrDirOpen(TestRemote): |
631 |
||
632 |
def make_fake_client_and_transport(self, path='quack'): |
|
633 |
transport = MemoryTransport() |
|
634 |
transport.mkdir(path) |
|
635 |
transport = transport.clone(path) |
|
636 |
client = FakeClient(transport.base) |
|
637 |
return client, transport |
|
638 |
||
639 |
def test_absent(self): |
|
640 |
client, transport = self.make_fake_client_and_transport() |
|
641 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
642 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'no',)) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
643 |
self.assertRaises(errors.NotBranchError, RemoteBzrDir, transport, |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
644 |
RemoteBzrDirFormat(), _client=client, |
645 |
_force_probe=True) |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
646 |
self.assertFinished(client) |
647 |
||
648 |
def test_present_without_workingtree(self): |
|
649 |
client, transport = self.make_fake_client_and_transport() |
|
650 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
651 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'yes', b'no')) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
652 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
653 |
_client=client, _force_probe=True) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
654 |
self.assertIsInstance(bd, RemoteBzrDir) |
655 |
self.assertFalse(bd.has_workingtree()) |
|
656 |
self.assertRaises(errors.NoWorkingTree, bd.open_workingtree) |
|
657 |
self.assertFinished(client) |
|
658 |
||
659 |
def test_present_with_workingtree(self): |
|
660 |
client, transport = self.make_fake_client_and_transport() |
|
661 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
662 |
b'BzrDir.open_2.1', (b'quack/',), b'success', (b'yes', b'yes')) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
663 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
664 |
_client=client, _force_probe=True) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
665 |
self.assertIsInstance(bd, RemoteBzrDir) |
666 |
self.assertTrue(bd.has_workingtree()) |
|
667 |
self.assertRaises(errors.NotLocalUrl, bd.open_workingtree) |
|
668 |
self.assertFinished(client) |
|
669 |
||
670 |
def test_backwards_compat(self): |
|
671 |
client, transport = self.make_fake_client_and_transport() |
|
672 |
client.add_expected_call( |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
673 |
b'BzrDir.open_2.1', (b'quack/',), b'unknown', |
674 |
(b'BzrDir.open_2.1',)) |
|
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
675 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
676 |
b'BzrDir.open', (b'quack/',), b'success', (b'yes',)) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
677 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
678 |
_client=client, _force_probe=True) |
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
679 |
self.assertIsInstance(bd, RemoteBzrDir) |
680 |
self.assertFinished(client) |
|
681 |
||
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
682 |
def test_backwards_compat_hpss_v2(self): |
683 |
client, transport = self.make_fake_client_and_transport() |
|
684 |
# Monkey-patch fake client to simulate real-world behaviour with v2
|
|
685 |
# server: upon first RPC call detect the protocol version, and because
|
|
686 |
# the version is 2 also do _remember_remote_is_before((1, 6)) before
|
|
687 |
# continuing with the RPC.
|
|
688 |
orig_check_call = client._check_call |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
689 |
|
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
690 |
def check_call(method, args): |
691 |
client._medium._protocol_version = 2 |
|
692 |
client._medium._remember_remote_is_before((1, 6)) |
|
693 |
client._check_call = orig_check_call |
|
694 |
client._check_call(method, args) |
|
695 |
client._check_call = check_call |
|
696 |
client.add_expected_call( |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
697 |
b'BzrDir.open_2.1', (b'quack/',), b'unknown', |
698 |
(b'BzrDir.open_2.1',)) |
|
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
699 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
700 |
b'BzrDir.open', (b'quack/',), b'success', (b'yes',)) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
701 |
bd = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
702 |
_client=client, _force_probe=True) |
|
4797.49.2
by Andrew Bennetts
Add test that demonstrates bug #528041. |
703 |
self.assertIsInstance(bd, RemoteBzrDir) |
704 |
self.assertFinished(client) |
|
705 |
||
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
706 |
|
|
4053.1.2
by Robert Collins
Actually make this branch work. |
707 |
class TestBzrDirOpenBranch(TestRemote): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
708 |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
709 |
def test_backwards_compat(self): |
710 |
self.setup_smart_server_with_call_log() |
|
711 |
self.make_branch('.') |
|
712 |
a_dir = BzrDir.open(self.get_url('.')) |
|
713 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
714 |
verb = b'BzrDir.open_branchV3' |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
715 |
self.disable_verb(verb) |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
716 |
a_dir.open_branch() |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
717 |
call_count = len([call for call in self.hpss_calls if |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
718 |
call.call.method == verb]) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
719 |
self.assertEqual(1, call_count) |
720 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
721 |
def test_branch_present(self): |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
722 |
reference_format = self.get_repo_format() |
723 |
network_name = reference_format.network_name() |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
724 |
branch_network_name = self.get_branch_format().network_name() |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
725 |
transport = MemoryTransport() |
726 |
transport.mkdir('quack') |
|
727 |
transport = transport.clone('quack') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
728 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
729 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
730 |
b'BzrDir.open_branchV3', (b'quack/',), |
731 |
b'success', (b'branch', branch_network_name)) |
|
732 |
client.add_expected_call( |
|
733 |
b'BzrDir.find_repositoryV3', (b'quack/',), |
|
734 |
b'success', (b'ok', b'', b'no', b'no', b'no', network_name)) |
|
735 |
client.add_expected_call( |
|
736 |
b'Branch.get_stacked_on_url', (b'quack/',), |
|
737 |
b'error', (b'NotStacked',)) |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
738 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
739 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
740 |
result = bzrdir.open_branch() |
741 |
self.assertIsInstance(result, RemoteBranch) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
742 |
self.assertEqual(bzrdir, result.controldir) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
743 |
self.assertFinished(client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
744 |
|
745 |
def test_branch_missing(self): |
|
746 |
transport = MemoryTransport() |
|
747 |
transport.mkdir('quack') |
|
748 |
transport = transport.clone('quack') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
749 |
client = FakeClient(transport.base) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
750 |
client.add_error_response(b'nobranch') |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
751 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
752 |
_client=client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
753 |
self.assertRaises(errors.NotBranchError, bzrdir.open_branch) |
754 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
755 |
[('call', b'BzrDir.open_branchV3', (b'quack/',))], |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
756 |
client._calls) |
757 |
||
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
758 |
def test__get_tree_branch(self): |
759 |
# _get_tree_branch is a form of open_branch, but it should only ask for
|
|
760 |
# branch opening, not any other network requests.
|
|
761 |
calls = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
762 |
|
|
6305.3.4
by Jelmer Vernooij
Add possible_transports in a couple more places. |
763 |
def open_branch(name=None, possible_transports=None): |
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
764 |
calls.append("Called") |
765 |
return "a-branch" |
|
766 |
transport = MemoryTransport() |
|
767 |
# no requests on the network - catches other api calls being made.
|
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
768 |
client = FakeClient(transport.base) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
769 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
770 |
_client=client) |
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
771 |
# patch the open_branch call to record that it was called.
|
772 |
bzrdir.open_branch = open_branch |
|
773 |
self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch()) |
|
774 |
self.assertEqual(["Called"], calls) |
|
775 |
self.assertEqual([], client._calls) |
|
776 |
||
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
777 |
def test_url_quoting_of_path(self): |
778 |
# Relpaths on the wire should not be URL-escaped. So "~" should be
|
|
779 |
# transmitted as "~", not "%7E".
|
|
|
3431.3.1
by Andrew Bennetts
First rough cut of a fix for bug #230550, by adding .base to SmartClientMedia rather than relying on other objects to track this accurately while reusing client media. |
780 |
transport = RemoteTCPTransport('bzr://localhost/~hello/') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
781 |
client = FakeClient(transport.base) |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
782 |
reference_format = self.get_repo_format() |
783 |
network_name = reference_format.network_name() |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
784 |
branch_network_name = self.get_branch_format().network_name() |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
785 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
786 |
b'BzrDir.open_branchV3', (b'~hello/',), |
787 |
b'success', (b'branch', branch_network_name)) |
|
788 |
client.add_expected_call( |
|
789 |
b'BzrDir.find_repositoryV3', (b'~hello/',), |
|
790 |
b'success', (b'ok', b'', b'no', b'no', b'no', network_name)) |
|
791 |
client.add_expected_call( |
|
792 |
b'Branch.get_stacked_on_url', (b'~hello/',), |
|
793 |
b'error', (b'NotStacked',)) |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
794 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
795 |
_client=client) |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
796 |
bzrdir.open_branch() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
797 |
self.assertFinished(client) |
|
3192.2.1
by Andrew Bennetts
Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier. |
798 |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
799 |
def check_open_repository(self, rich_root, subtrees, |
800 |
external_lookup=b'no'): |
|
|
4053.1.2
by Robert Collins
Actually make this branch work. |
801 |
reference_format = self.get_repo_format() |
802 |
network_name = reference_format.network_name() |
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
803 |
transport = MemoryTransport() |
804 |
transport.mkdir('quack') |
|
805 |
transport = transport.clone('quack') |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
806 |
if rich_root: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
807 |
rich_response = b'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
808 |
else: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
809 |
rich_response = b'no' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
810 |
if subtrees: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
811 |
subtree_response = b'yes' |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
812 |
else: |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
813 |
subtree_response = b'no' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
814 |
client = FakeClient(transport.base) |
815 |
client.add_success_response( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
816 |
b'ok', b'', rich_response, subtree_response, external_lookup, |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
817 |
network_name) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
818 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
819 |
_client=client) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
820 |
result = bzrdir.open_repository() |
821 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
822 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',))], |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
823 |
client._calls) |
824 |
self.assertIsInstance(result, RemoteRepository) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
825 |
self.assertEqual(bzrdir, result.controldir) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
826 |
self.assertEqual(rich_root, result._format.rich_root_data) |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
827 |
self.assertEqual(subtrees, result._format.supports_tree_reference) |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
828 |
|
829 |
def test_open_repository_sets_format_attributes(self): |
|
830 |
self.check_open_repository(True, True) |
|
831 |
self.check_open_repository(False, True) |
|
832 |
self.check_open_repository(True, False) |
|
833 |
self.check_open_repository(False, False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
834 |
self.check_open_repository(False, False, b'yes') |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
835 |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
836 |
def test_old_server(self): |
837 |
"""RemoteBzrDirFormat should fail to probe if the server version is too |
|
838 |
old.
|
|
839 |
"""
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
840 |
self.assertRaises( |
841 |
errors.NotBranchError, |
|
842 |
RemoteBzrProber.probe_transport, OldServerTransport()) |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
843 |
|
844 |
||
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
845 |
class TestBzrDirCreateBranch(TestRemote): |
846 |
||
847 |
def test_backwards_compat(self): |
|
848 |
self.setup_smart_server_with_call_log() |
|
849 |
repo = self.make_repository('.') |
|
850 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
851 |
self.disable_verb(b'BzrDir.create_branch') |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
852 |
repo.controldir.create_branch() |
853 |
create_branch_call_count = len( |
|
854 |
[call for call in self.hpss_calls |
|
855 |
if call.call.method == b'BzrDir.create_branch']) |
|
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
856 |
self.assertEqual(1, create_branch_call_count) |
857 |
||
858 |
def test_current_server(self): |
|
859 |
transport = self.get_transport('.') |
|
860 |
transport = transport.clone('quack') |
|
861 |
self.make_repository('quack') |
|
862 |
client = FakeClient(transport.base) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
863 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
864 |
reference_format = reference_bzrdir_format.get_branch_format() |
865 |
network_name = reference_format.network_name() |
|
866 |
reference_repo_fmt = reference_bzrdir_format.repository_format |
|
867 |
reference_repo_name = reference_repo_fmt.network_name() |
|
868 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
869 |
b'BzrDir.create_branch', (b'quack/', network_name), |
870 |
b'success', (b'ok', network_name, b'', b'no', b'no', b'yes', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
871 |
reference_repo_name)) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
872 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
873 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
874 |
branch = a_controldir.create_branch() |
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
875 |
# We should have got a remote branch
|
876 |
self.assertIsInstance(branch, remote.RemoteBranch) |
|
877 |
# its format should have the settings from the response
|
|
878 |
format = branch._format |
|
879 |
self.assertEqual(network_name, format.network_name()) |
|
880 |
||
|
5609.21.2
by Andrew Bennetts
Add test. |
881 |
def test_already_open_repo_and_reused_medium(self): |
882 |
"""Bug 726584: create_branch(..., repository=repo) should work |
|
883 |
regardless of what the smart medium's base URL is.
|
|
884 |
"""
|
|
885 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
886 |
transport = self.get_transport('.') |
|
887 |
repo = self.make_repository('quack') |
|
888 |
# Client's medium rooted a transport root (not at the bzrdir)
|
|
889 |
client = FakeClient(transport.base) |
|
890 |
transport = transport.clone('quack') |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
891 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
5609.21.2
by Andrew Bennetts
Add test. |
892 |
reference_format = reference_bzrdir_format.get_branch_format() |
893 |
network_name = reference_format.network_name() |
|
894 |
reference_repo_fmt = reference_bzrdir_format.repository_format |
|
895 |
reference_repo_name = reference_repo_fmt.network_name() |
|
896 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
897 |
b'BzrDir.create_branch', (b'extra/quack/', network_name), |
898 |
b'success', (b'ok', network_name, b'', b'no', b'no', b'yes', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
899 |
reference_repo_name)) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
900 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
901 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
902 |
branch = a_controldir.create_branch(repository=repo) |
|
5609.21.2
by Andrew Bennetts
Add test. |
903 |
# We should have got a remote branch
|
904 |
self.assertIsInstance(branch, remote.RemoteBranch) |
|
905 |
# its format should have the settings from the response
|
|
906 |
format = branch._format |
|
907 |
self.assertEqual(network_name, format.network_name()) |
|
908 |
||
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
909 |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
910 |
class TestBzrDirCreateRepository(TestRemote): |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
911 |
|
912 |
def test_backwards_compat(self): |
|
913 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
914 |
bzrdir = self.make_controldir('.') |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
915 |
self.reset_smart_call_log() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
916 |
self.disable_verb(b'BzrDir.create_repository') |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
917 |
bzrdir.create_repository() |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
918 |
create_repo_call_count = len([call for call in self.hpss_calls if |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
919 |
call.call.method == b'BzrDir.create_repository']) |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
920 |
self.assertEqual(1, create_repo_call_count) |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
921 |
|
922 |
def test_current_server(self): |
|
923 |
transport = self.get_transport('.') |
|
924 |
transport = transport.clone('quack') |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
925 |
self.make_controldir('quack') |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
926 |
client = FakeClient(transport.base) |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
927 |
reference_bzrdir_format = controldir.format_registry.get('default')() |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
928 |
reference_format = reference_bzrdir_format.repository_format |
929 |
network_name = reference_format.network_name() |
|
930 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
931 |
b'BzrDir.create_repository', (b'quack/', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
932 |
b'Bazaar repository format 2a (needs bzr 1.16 or later)\n', |
933 |
b'False'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
934 |
b'success', (b'ok', b'yes', b'yes', b'yes', network_name)) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
935 |
a_controldir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
936 |
_client=client) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
937 |
repo = a_controldir.create_repository() |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
938 |
# We should have got a remote repository
|
939 |
self.assertIsInstance(repo, remote.RemoteRepository) |
|
940 |
# its format should have the settings from the response
|
|
941 |
format = repo._format |
|
|
4599.4.20
by Robert Collins
Prep test_remote for 2a as default. |
942 |
self.assertTrue(format.rich_root_data) |
943 |
self.assertTrue(format.supports_tree_reference) |
|
944 |
self.assertTrue(format.supports_external_lookups) |
|
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
945 |
self.assertEqual(network_name, format.network_name()) |
946 |
||
947 |
||
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
948 |
class TestBzrDirOpenRepository(TestRemote): |
949 |
||
950 |
def test_backwards_compat_1_2_3(self): |
|
951 |
# fallback all the way to the first version.
|
|
952 |
reference_format = self.get_repo_format() |
|
953 |
network_name = reference_format.network_name() |
|
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
954 |
server_url = 'bzr://example.com/' |
955 |
self.permit_url(server_url) |
|
956 |
client = FakeClient(server_url) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
957 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV3') |
958 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV2') |
|
959 |
client.add_success_response(b'ok', b'', b'no', b'no') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
960 |
# A real repository instance will be created to determine the network
|
961 |
# name.
|
|
962 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
963 |
b"Bazaar-NG meta directory, format 1\n", b'ok') |
964 |
client.add_success_response(b'stat', b'0', b'65535') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
965 |
client.add_success_response_with_body( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
966 |
reference_format.get_format_string(), b'ok') |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
967 |
# PackRepository wants to do a stat
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
968 |
client.add_success_response(b'stat', b'0', b'65535') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
969 |
remote_transport = RemoteTransport(server_url + 'quack/', medium=False, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
970 |
_client=client) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
971 |
bzrdir = RemoteBzrDir(remote_transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
972 |
_client=client) |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
973 |
repo = bzrdir.open_repository() |
974 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
975 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',)), |
976 |
('call', b'BzrDir.find_repositoryV2', (b'quack/',)), |
|
977 |
('call', b'BzrDir.find_repository', (b'quack/',)), |
|
978 |
('call_expecting_body', b'get', (b'/quack/.bzr/branch-format',)), |
|
979 |
('call', b'stat', (b'/quack/.bzr',)), |
|
980 |
('call_expecting_body', b'get', (b'/quack/.bzr/repository/format',)), |
|
981 |
('call', b'stat', (b'/quack/.bzr/repository',)), |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
982 |
],
|
983 |
client._calls) |
|
984 |
self.assertEqual(network_name, repo._format.network_name()) |
|
985 |
||
986 |
def test_backwards_compat_2(self): |
|
987 |
# fallback to find_repositoryV2
|
|
988 |
reference_format = self.get_repo_format() |
|
989 |
network_name = reference_format.network_name() |
|
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
990 |
server_url = 'bzr://example.com/' |
991 |
self.permit_url(server_url) |
|
992 |
client = FakeClient(server_url) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
993 |
client.add_unknown_method_response(b'BzrDir.find_repositoryV3') |
994 |
client.add_success_response(b'ok', b'', b'no', b'no', b'no') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
995 |
# A real repository instance will be created to determine the network
|
996 |
# name.
|
|
997 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
998 |
b"Bazaar-NG meta directory, format 1\n", b'ok') |
999 |
client.add_success_response(b'stat', b'0', b'65535') |
|
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1000 |
client.add_success_response_with_body( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1001 |
reference_format.get_format_string(), b'ok') |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1002 |
# PackRepository wants to do a stat
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1003 |
client.add_success_response(b'stat', b'0', b'65535') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1004 |
remote_transport = RemoteTransport(server_url + 'quack/', medium=False, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1005 |
_client=client) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1006 |
bzrdir = RemoteBzrDir(remote_transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1007 |
_client=client) |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1008 |
repo = bzrdir.open_repository() |
1009 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1010 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',)), |
1011 |
('call', b'BzrDir.find_repositoryV2', (b'quack/',)), |
|
1012 |
('call_expecting_body', b'get', (b'/quack/.bzr/branch-format',)), |
|
1013 |
('call', b'stat', (b'/quack/.bzr',)), |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1014 |
('call_expecting_body', b'get', |
1015 |
(b'/quack/.bzr/repository/format',)), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1016 |
('call', b'stat', (b'/quack/.bzr/repository',)), |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1017 |
],
|
1018 |
client._calls) |
|
1019 |
self.assertEqual(network_name, repo._format.network_name()) |
|
1020 |
||
1021 |
def test_current_server(self): |
|
1022 |
reference_format = self.get_repo_format() |
|
1023 |
network_name = reference_format.network_name() |
|
1024 |
transport = MemoryTransport() |
|
1025 |
transport.mkdir('quack') |
|
1026 |
transport = transport.clone('quack') |
|
1027 |
client = FakeClient(transport.base) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1028 |
client.add_success_response( |
1029 |
b'ok', b'', b'no', b'no', b'no', network_name) |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1030 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1031 |
_client=client) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
1032 |
repo = bzrdir.open_repository() |
1033 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1034 |
[('call', b'BzrDir.find_repositoryV3', (b'quack/',))], |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
1035 |
client._calls) |
|
4053.1.1
by Robert Collins
New version of the BzrDir.find_repository verb supporting _network_name to support removing more _ensure_real calls. |
1036 |
self.assertEqual(network_name, repo._format.network_name()) |
|
3297.3.3
by Andrew Bennetts
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod. Callers no longer need to do their own ad hoc unknown smart method error detection. |
1037 |
|
1038 |
||
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1039 |
class TestBzrDirFormatInitializeEx(TestRemote): |
1040 |
||
1041 |
def test_success(self): |
|
1042 |
"""Simple test for typical successful call.""" |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1043 |
fmt = RemoteBzrDirFormat() |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1044 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
1045 |
transport = self.get_transport() |
|
1046 |
client = FakeClient(transport.base) |
|
1047 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1048 |
b'BzrDirFormat.initialize_ex_1.16', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1049 |
(default_format_name, b'path', b'False', b'False', b'False', b'', |
1050 |
b'', b'', b'', b'False'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1051 |
b'success', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1052 |
(b'.', b'no', b'no', b'yes', b'repo fmt', b'repo bzrdir fmt', |
1053 |
b'bzrdir fmt', b'False', b'', b'', b'repo lock token')) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1054 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
1055 |
# it's currently hard to test that without supplying a real remote
|
|
1056 |
# transport connected to a real server.
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1057 |
fmt._initialize_on_transport_ex_rpc( |
1058 |
client, b'path', transport, False, False, False, None, None, None, |
|
1059 |
None, False) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1060 |
self.assertFinished(client) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1061 |
|
1062 |
def test_error(self): |
|
1063 |
"""Error responses are translated, e.g. 'PermissionDenied' raises the |
|
1064 |
corresponding error from the client.
|
|
1065 |
"""
|
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1066 |
fmt = RemoteBzrDirFormat() |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1067 |
default_format_name = BzrDirFormat.get_default_format().network_name() |
1068 |
transport = self.get_transport() |
|
1069 |
client = FakeClient(transport.base) |
|
1070 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1071 |
b'BzrDirFormat.initialize_ex_1.16', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1072 |
(default_format_name, b'path', b'False', b'False', b'False', b'', |
1073 |
b'', b'', b'', b'False'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1074 |
b'error', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1075 |
(b'PermissionDenied', b'path', b'extra info')) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1076 |
# XXX: It would be better to call fmt.initialize_on_transport_ex, but
|
1077 |
# it's currently hard to test that without supplying a real remote
|
|
1078 |
# transport connected to a real server.
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1079 |
err = self.assertRaises( |
1080 |
errors.PermissionDenied, |
|
1081 |
fmt._initialize_on_transport_ex_rpc, client, b'path', transport, |
|
1082 |
False, False, False, None, None, None, None, False) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1083 |
self.assertEqual('path', err.path) |
1084 |
self.assertEqual(': extra info', err.extra) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1085 |
self.assertFinished(client) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1086 |
|
|
4384.1.3
by Andrew Bennetts
Add test suggested by John. |
1087 |
def test_error_from_real_server(self): |
1088 |
"""Integration test for error translation.""" |
|
1089 |
transport = self.make_smart_server('foo') |
|
1090 |
transport = transport.clone('no-such-path') |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1091 |
fmt = RemoteBzrDirFormat() |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1092 |
self.assertRaises( |
1093 |
errors.NoSuchFile, fmt.initialize_on_transport_ex, transport, |
|
1094 |
create_prefix=False) |
|
|
4384.1.3
by Andrew Bennetts
Add test suggested by John. |
1095 |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
1096 |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1097 |
class OldSmartClient(object): |
1098 |
"""A fake smart client for test_old_version that just returns a version one |
|
1099 |
response to the 'hello' (query version) command.
|
|
1100 |
"""
|
|
1101 |
||
1102 |
def get_request(self): |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
1103 |
input_file = BytesIO(b'ok\x011\n') |
1104 |
output_file = BytesIO() |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1105 |
client_medium = medium.SmartSimplePipesClientMedium( |
1106 |
input_file, output_file) |
|
1107 |
return medium.SmartClientStreamMediumRequest(client_medium) |
|
1108 |
||
|
3241.1.1
by Andrew Bennetts
Shift protocol version querying from RemoteBzrDirFormat into SmartClientMedium. |
1109 |
def protocol_version(self): |
1110 |
return 1 |
|
1111 |
||
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
1112 |
|
1113 |
class OldServerTransport(object): |
|
1114 |
"""A fake transport for test_old_server that reports it's smart server |
|
1115 |
protocol version as version one.
|
|
1116 |
"""
|
|
1117 |
||
1118 |
def __init__(self): |
|
1119 |
self.base = 'fake:' |
|
1120 |
||
1121 |
def get_smart_client(self): |
|
1122 |
return OldSmartClient() |
|
1123 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1124 |
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1125 |
class RemoteBzrDirTestCase(TestRemote): |
1126 |
||
1127 |
def make_remote_bzrdir(self, transport, client): |
|
1128 |
"""Make a RemotebzrDir using 'client' as the _client.""" |
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1129 |
return RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1130 |
_client=client) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1131 |
|
1132 |
||
1133 |
class RemoteBranchTestCase(RemoteBzrDirTestCase): |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1134 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1135 |
def lock_remote_branch(self, branch): |
1136 |
"""Trick a RemoteBranch into thinking it is locked.""" |
|
1137 |
branch._lock_mode = 'w' |
|
1138 |
branch._lock_count = 2 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1139 |
branch._lock_token = b'branch token' |
1140 |
branch._repo_lock_token = b'repo token' |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1141 |
branch.repository._lock_mode = 'w' |
1142 |
branch.repository._lock_count = 2 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1143 |
branch.repository._lock_token = b'repo token' |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1144 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1145 |
def make_remote_branch(self, transport, client): |
1146 |
"""Make a RemoteBranch using 'client' as its _SmartClient. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1147 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1148 |
A RemoteBzrDir and RemoteRepository will also be created to fill out
|
1149 |
the RemoteBranch, albeit with stub values for some of their attributes.
|
|
1150 |
"""
|
|
1151 |
# we do not want bzrdir to make any remote calls, so use False as its
|
|
1152 |
# _client. If it tries to make a remote call, this will fail
|
|
1153 |
# immediately.
|
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1154 |
bzrdir = self.make_remote_bzrdir(transport, False) |
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1155 |
repo = RemoteRepository(bzrdir, None, _client=client) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1156 |
branch_format = self.get_branch_format() |
1157 |
format = RemoteBranchFormat(network_name=branch_format.network_name()) |
|
1158 |
return RemoteBranch(bzrdir, repo, _client=client, format=format) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1159 |
|
1160 |
||
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1161 |
class TestBranchBreakLock(RemoteBranchTestCase): |
1162 |
||
1163 |
def test_break_lock(self): |
|
1164 |
transport = MemoryTransport() |
|
1165 |
client = FakeClient(transport.base) |
|
1166 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1167 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1168 |
b'error', (b'NotStacked',)) |
|
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1169 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1170 |
b'Branch.break_lock', (b'quack/',), |
1171 |
b'success', (b'ok',)) |
|
|
6280.4.3
by Jelmer Vernooij
add Branch.break_lock. |
1172 |
transport.mkdir('quack') |
1173 |
transport = transport.clone('quack') |
|
1174 |
branch = self.make_remote_branch(transport, client) |
|
1175 |
branch.break_lock() |
|
1176 |
self.assertFinished(client) |
|
1177 |
||
1178 |
||
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1179 |
class TestBranchGetPhysicalLockStatus(RemoteBranchTestCase): |
1180 |
||
1181 |
def test_get_physical_lock_status_yes(self): |
|
1182 |
transport = MemoryTransport() |
|
1183 |
client = FakeClient(transport.base) |
|
1184 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1185 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1186 |
b'error', (b'NotStacked',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1187 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1188 |
b'Branch.get_physical_lock_status', (b'quack/',), |
1189 |
b'success', (b'yes',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1190 |
transport.mkdir('quack') |
1191 |
transport = transport.clone('quack') |
|
1192 |
branch = self.make_remote_branch(transport, client) |
|
1193 |
result = branch.get_physical_lock_status() |
|
1194 |
self.assertFinished(client) |
|
1195 |
self.assertEqual(True, result) |
|
1196 |
||
1197 |
def test_get_physical_lock_status_no(self): |
|
1198 |
transport = MemoryTransport() |
|
1199 |
client = FakeClient(transport.base) |
|
1200 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1201 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1202 |
b'error', (b'NotStacked',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1203 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1204 |
b'Branch.get_physical_lock_status', (b'quack/',), |
1205 |
b'success', (b'no',)) |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
1206 |
transport.mkdir('quack') |
1207 |
transport = transport.clone('quack') |
|
1208 |
branch = self.make_remote_branch(transport, client) |
|
1209 |
result = branch.get_physical_lock_status() |
|
1210 |
self.assertFinished(client) |
|
1211 |
self.assertEqual(False, result) |
|
1212 |
||
1213 |
||
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1214 |
class TestBranchGetParent(RemoteBranchTestCase): |
1215 |
||
1216 |
def test_no_parent(self): |
|
1217 |
# in an empty branch we decode the response properly
|
|
1218 |
transport = MemoryTransport() |
|
1219 |
client = FakeClient(transport.base) |
|
1220 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1221 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1222 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1223 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1224 |
b'Branch.get_parent', (b'quack/',), |
1225 |
b'success', (b'',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1226 |
transport.mkdir('quack') |
1227 |
transport = transport.clone('quack') |
|
1228 |
branch = self.make_remote_branch(transport, client) |
|
1229 |
result = branch.get_parent() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1230 |
self.assertFinished(client) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1231 |
self.assertEqual(None, result) |
1232 |
||
1233 |
def test_parent_relative(self): |
|
1234 |
transport = MemoryTransport() |
|
1235 |
client = FakeClient(transport.base) |
|
1236 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1237 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1238 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1239 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1240 |
b'Branch.get_parent', (b'kwaak/',), |
1241 |
b'success', (b'../foo/',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1242 |
transport.mkdir('kwaak') |
1243 |
transport = transport.clone('kwaak') |
|
1244 |
branch = self.make_remote_branch(transport, client) |
|
1245 |
result = branch.get_parent() |
|
1246 |
self.assertEqual(transport.clone('../foo').base, result) |
|
1247 |
||
1248 |
def test_parent_absolute(self): |
|
1249 |
transport = MemoryTransport() |
|
1250 |
client = FakeClient(transport.base) |
|
1251 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1252 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1253 |
b'error', (b'NotStacked',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1254 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1255 |
b'Branch.get_parent', (b'kwaak/',), |
1256 |
b'success', (b'http://foo/',)) |
|
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1257 |
transport.mkdir('kwaak') |
1258 |
transport = transport.clone('kwaak') |
|
1259 |
branch = self.make_remote_branch(transport, client) |
|
1260 |
result = branch.get_parent() |
|
1261 |
self.assertEqual('http://foo/', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1262 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1263 |
|
1264 |
||
1265 |
class TestBranchSetParentLocation(RemoteBranchTestCase): |
|
1266 |
||
1267 |
def test_no_parent(self): |
|
1268 |
# We call the verb when setting parent to None
|
|
1269 |
transport = MemoryTransport() |
|
1270 |
client = FakeClient(transport.base) |
|
1271 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1272 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1273 |
b'error', (b'NotStacked',)) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1274 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1275 |
b'Branch.set_parent_location', (b'quack/', b'b', b'r', b''), |
1276 |
b'success', ()) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1277 |
transport.mkdir('quack') |
1278 |
transport = transport.clone('quack') |
|
1279 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1280 |
branch._lock_token = b'b' |
1281 |
branch._repo_lock_token = b'r' |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1282 |
branch._set_parent_location(None) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1283 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1284 |
|
1285 |
def test_parent(self): |
|
1286 |
transport = MemoryTransport() |
|
1287 |
client = FakeClient(transport.base) |
|
1288 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1289 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1290 |
b'error', (b'NotStacked',)) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1291 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1292 |
b'Branch.set_parent_location', (b'kwaak/', b'b', b'r', b'foo'), |
1293 |
b'success', ()) |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1294 |
transport.mkdir('kwaak') |
1295 |
transport = transport.clone('kwaak') |
|
1296 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1297 |
branch._lock_token = b'b' |
1298 |
branch._repo_lock_token = b'r' |
|
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1299 |
branch._set_parent_location('foo') |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1300 |
self.assertFinished(client) |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1301 |
|
1302 |
def test_backwards_compat(self): |
|
1303 |
self.setup_smart_server_with_call_log() |
|
1304 |
branch = self.make_branch('.') |
|
1305 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1306 |
verb = b'Branch.set_parent_location' |
|
4288.1.7
by Robert Collins
Add new remote server verb Branch.set_parent_location, dropping roundtrips further on push operations. |
1307 |
self.disable_verb(verb) |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1308 |
branch.set_parent('http://foo/') |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1309 |
self.assertLength(14, self.hpss_calls) |
|
4078.2.1
by Robert Collins
Add a Branch.get_parent remote call for RemoteBranch. |
1310 |
|
1311 |
||
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1312 |
class TestBranchGetTagsBytes(RemoteBranchTestCase): |
1313 |
||
1314 |
def test_backwards_compat(self): |
|
1315 |
self.setup_smart_server_with_call_log() |
|
1316 |
branch = self.make_branch('.') |
|
1317 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1318 |
verb = b'Branch.get_tags_bytes' |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1319 |
self.disable_verb(verb) |
1320 |
branch.tags.get_tag_dict() |
|
1321 |
call_count = len([call for call in self.hpss_calls if |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1322 |
call.call.method == verb]) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1323 |
self.assertEqual(1, call_count) |
1324 |
||
1325 |
def test_trivial(self): |
|
1326 |
transport = MemoryTransport() |
|
1327 |
client = FakeClient(transport.base) |
|
1328 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1329 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1330 |
b'error', (b'NotStacked',)) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1331 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1332 |
b'Branch.get_tags_bytes', (b'quack/',), |
1333 |
b'success', (b'',)) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1334 |
transport.mkdir('quack') |
1335 |
transport = transport.clone('quack') |
|
1336 |
branch = self.make_remote_branch(transport, client) |
|
1337 |
result = branch.tags.get_tag_dict() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1338 |
self.assertFinished(client) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1339 |
self.assertEqual({}, result) |
1340 |
||
1341 |
||
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1342 |
class TestBranchSetTagsBytes(RemoteBranchTestCase): |
1343 |
||
1344 |
def test_trivial(self): |
|
1345 |
transport = MemoryTransport() |
|
1346 |
client = FakeClient(transport.base) |
|
1347 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1348 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1349 |
b'error', (b'NotStacked',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1350 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1351 |
b'Branch.set_tags_bytes', (b'quack/', |
1352 |
b'branch token', b'repo token'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1353 |
b'success', ('',)) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1354 |
transport.mkdir('quack') |
1355 |
transport = transport.clone('quack') |
|
1356 |
branch = self.make_remote_branch(transport, client) |
|
1357 |
self.lock_remote_branch(branch) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1358 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1359 |
self.assertFinished(client) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1360 |
self.assertEqual(b'tags bytes', client._calls[-1][-1]) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1361 |
|
1362 |
def test_backwards_compatible(self): |
|
1363 |
transport = MemoryTransport() |
|
1364 |
client = FakeClient(transport.base) |
|
1365 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1366 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1367 |
b'error', (b'NotStacked',)) |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1368 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1369 |
b'Branch.set_tags_bytes', (b'quack/', |
1370 |
b'branch token', b'repo token'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1371 |
b'unknown', (b'Branch.set_tags_bytes',)) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1372 |
transport.mkdir('quack') |
1373 |
transport = transport.clone('quack') |
|
1374 |
branch = self.make_remote_branch(transport, client) |
|
1375 |
self.lock_remote_branch(branch) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1376 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1377 |
class StubRealBranch(object): |
1378 |
def __init__(self): |
|
1379 |
self.calls = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1380 |
|
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1381 |
def _set_tags_bytes(self, bytes): |
1382 |
self.calls.append(('set_tags_bytes', bytes)) |
|
1383 |
real_branch = StubRealBranch() |
|
1384 |
branch._real_branch = real_branch |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1385 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1386 |
# Call a second time, to exercise the 'remote version already inferred'
|
1387 |
# code path.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1388 |
branch._set_tags_bytes(b'tags bytes') |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1389 |
self.assertFinished(client) |
1390 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1391 |
[('set_tags_bytes', b'tags bytes')] * 2, real_branch.calls) |
|
4634.36.1
by Andrew Bennetts
Fix trivial bug in RemoteBranch._set_tags_bytes, and add some unit tests for it. |
1392 |
|
1393 |
||
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1394 |
class TestBranchHeadsToFetch(RemoteBranchTestCase): |
1395 |
||
1396 |
def test_uses_last_revision_info_and_tags_by_default(self): |
|
1397 |
transport = MemoryTransport() |
|
1398 |
client = FakeClient(transport.base) |
|
1399 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1400 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1401 |
b'error', (b'NotStacked',)) |
|
1402 |
client.add_expected_call( |
|
1403 |
b'Branch.last_revision_info', (b'quack/',), |
|
1404 |
b'success', (b'ok', b'1', b'rev-tip')) |
|
1405 |
client.add_expected_call( |
|
1406 |
b'Branch.get_config_file', (b'quack/',), |
|
|
6973.14.12
by Jelmer Vernooij
Merge trunk. |
1407 |
b'success', (b'ok',), b'') |
|
6015.15.4
by John Arbash Meinel
Catch a couple more cases that test tag fetching. |
1408 |
transport.mkdir('quack') |
1409 |
transport = transport.clone('quack') |
|
1410 |
branch = self.make_remote_branch(transport, client) |
|
1411 |
result = branch.heads_to_fetch() |
|
1412 |
self.assertFinished(client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1413 |
self.assertEqual(({b'rev-tip'}, set()), result) |
|
6015.15.4
by John Arbash Meinel
Catch a couple more cases that test tag fetching. |
1414 |
|
1415 |
def test_uses_last_revision_info_and_tags_when_set(self): |
|
1416 |
transport = MemoryTransport() |
|
1417 |
client = FakeClient(transport.base) |
|
1418 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1419 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1420 |
b'error', (b'NotStacked',)) |
|
1421 |
client.add_expected_call( |
|
1422 |
b'Branch.last_revision_info', (b'quack/',), |
|
1423 |
b'success', (b'ok', b'1', b'rev-tip')) |
|
1424 |
client.add_expected_call( |
|
1425 |
b'Branch.get_config_file', (b'quack/',), |
|
1426 |
b'success', (b'ok',), b'branch.fetch_tags = True') |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1427 |
# XXX: this will break if the default format's serialization of tags
|
1428 |
# changes, or if the RPC for fetching tags changes from get_tags_bytes.
|
|
1429 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1430 |
b'Branch.get_tags_bytes', (b'quack/',), |
1431 |
b'success', (b'd5:tag-17:rev-foo5:tag-27:rev-bare',)) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1432 |
transport.mkdir('quack') |
1433 |
transport = transport.clone('quack') |
|
1434 |
branch = self.make_remote_branch(transport, client) |
|
1435 |
result = branch.heads_to_fetch() |
|
1436 |
self.assertFinished(client) |
|
1437 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1438 |
({b'rev-tip'}, {b'rev-foo', b'rev-bar'}), result) |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1439 |
|
1440 |
def test_uses_rpc_for_formats_with_non_default_heads_to_fetch(self): |
|
1441 |
transport = MemoryTransport() |
|
1442 |
client = FakeClient(transport.base) |
|
1443 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1444 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1445 |
b'error', (b'NotStacked',)) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1446 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1447 |
b'Branch.heads_to_fetch', (b'quack/',), |
1448 |
b'success', ([b'tip'], [b'tagged-1', b'tagged-2'])) |
|
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1449 |
transport.mkdir('quack') |
1450 |
transport = transport.clone('quack') |
|
1451 |
branch = self.make_remote_branch(transport, client) |
|
|
5672.1.7
by Andrew Bennetts
Use a more explicit method name. |
1452 |
branch._format._use_default_local_heads_to_fetch = lambda: False |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1453 |
result = branch.heads_to_fetch() |
1454 |
self.assertFinished(client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1455 |
self.assertEqual(({b'tip'}, {b'tagged-1', b'tagged-2'}), result) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1456 |
|
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1457 |
def make_branch_with_tags(self): |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1458 |
self.setup_smart_server_with_call_log() |
1459 |
# Make a branch with a single revision.
|
|
1460 |
builder = self.make_branch_builder('foo') |
|
1461 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
1462 |
builder.build_snapshot(None, [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1463 |
('add', ('', b'root-id', 'directory', ''))], |
1464 |
revision_id=b'tip') |
|
|
5672.1.6
by Andrew Bennetts
Add another test. |
1465 |
builder.finish_series() |
1466 |
branch = builder.get_branch() |
|
1467 |
# Add two tags to that branch
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1468 |
branch.tags.set_tag('tag-1', b'rev-1') |
1469 |
branch.tags.set_tag('tag-2', b'rev-2') |
|
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1470 |
return branch |
1471 |
||
1472 |
def test_backwards_compatible(self): |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1473 |
br = self.make_branch_with_tags() |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1474 |
br.get_config_stack().set('branch.fetch_tags', True) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1475 |
self.addCleanup(br.lock_read().unlock) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1476 |
# Disable the heads_to_fetch verb
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1477 |
verb = b'Branch.heads_to_fetch' |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1478 |
self.disable_verb(verb) |
1479 |
self.reset_smart_call_log() |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1480 |
result = br.heads_to_fetch() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1481 |
self.assertEqual(({b'tip'}, {b'rev-1', b'rev-2'}), result) |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1482 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1483 |
[b'Branch.last_revision_info', b'Branch.get_tags_bytes'], |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1484 |
[call.call.method for call in self.hpss_calls]) |
1485 |
||
1486 |
def test_backwards_compatible_no_tags(self): |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1487 |
br = self.make_branch_with_tags() |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
1488 |
br.get_config_stack().set('branch.fetch_tags', False) |
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1489 |
self.addCleanup(br.lock_read().unlock) |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1490 |
# Disable the heads_to_fetch verb
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1491 |
verb = b'Branch.heads_to_fetch' |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1492 |
self.disable_verb(verb) |
1493 |
self.reset_smart_call_log() |
|
|
6404.6.2
by Vincent Ladeuil
Merge trunk resolving conflicts and fixing more test failures related to |
1494 |
result = br.heads_to_fetch() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1495 |
self.assertEqual(({b'tip'}, set()), result) |
|
6015.15.1
by John Arbash Meinel
Start working on a config entry for testing whether we should fetch tags or not. |
1496 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1497 |
[b'Branch.last_revision_info'], |
|
5672.1.6
by Andrew Bennetts
Add another test. |
1498 |
[call.call.method for call in self.hpss_calls]) |
|
5672.1.5
by Andrew Bennetts
Add some tests for RemoteBranch.heads_to_fetch, and add release-note. |
1499 |
|
1500 |
||
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1501 |
class TestBranchLastRevisionInfo(RemoteBranchTestCase): |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1502 |
|
1503 |
def test_empty_branch(self): |
|
1504 |
# in an empty branch we decode the response properly
|
|
1505 |
transport = MemoryTransport() |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1506 |
client = FakeClient(transport.base) |
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1507 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1508 |
b'Branch.get_stacked_on_url', (b'quack/',), |
1509 |
b'error', (b'NotStacked',)) |
|
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1510 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1511 |
b'Branch.last_revision_info', (b'quack/',), |
1512 |
b'success', (b'ok', b'0', b'null:')) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1513 |
transport.mkdir('quack') |
1514 |
transport = transport.clone('quack') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1515 |
branch = self.make_remote_branch(transport, client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1516 |
result = branch.last_revision_info() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1517 |
self.assertFinished(client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1518 |
self.assertEqual((0, NULL_REVISION), result) |
1519 |
||
1520 |
def test_non_empty_branch(self): |
|
1521 |
# in a non-empty branch we also decode the response properly
|
|
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1522 |
revid = u'\xc8'.encode('utf8') |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1523 |
transport = MemoryTransport() |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1524 |
client = FakeClient(transport.base) |
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1525 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1526 |
b'Branch.get_stacked_on_url', (b'kwaak/',), |
1527 |
b'error', (b'NotStacked',)) |
|
|
3691.2.8
by Martin Pool
Update some test_remote tests for Branch.get_stacked_on_url and with clearer assertions |
1528 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1529 |
b'Branch.last_revision_info', (b'kwaak/',), |
1530 |
b'success', (b'ok', b'2', revid)) |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1531 |
transport.mkdir('kwaak') |
1532 |
transport = transport.clone('kwaak') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1533 |
branch = self.make_remote_branch(transport, client) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1534 |
result = branch.last_revision_info() |
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
1535 |
self.assertEqual((2, revid), result) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
1536 |
|
1537 |
||
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1538 |
class TestBranch_get_stacked_on_url(TestRemote): |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1539 |
"""Test Branch._get_stacked_on_url rpc""" |
1540 |
||
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1541 |
def test_get_stacked_on_invalid_url(self): |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1542 |
# test that asking for a stacked on url the server can't access works.
|
1543 |
# This isn't perfect, but then as we're in the same process there
|
|
1544 |
# really isn't anything we can do to be 100% sure that the server
|
|
1545 |
# doesn't just open in - this test probably needs to be rewritten using
|
|
1546 |
# a spawn()ed server.
|
|
1547 |
stacked_branch = self.make_branch('stacked', format='1.9') |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1548 |
self.make_branch('base', format='1.9') |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1549 |
vfs_url = self.get_vfs_only_url('base') |
1550 |
stacked_branch.set_stacked_on_url(vfs_url) |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
1551 |
transport = stacked_branch.controldir.root_transport |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1552 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1553 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1554 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
|
7045.2.18
by Jelmer Vernooij
Some fixes. |
1555 |
b'success', (b'ok', vfs_url.encode('utf-8'))) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1556 |
# XXX: Multiple calls are bad, this second call documents what is
|
1557 |
# today.
|
|
1558 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1559 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
|
7045.2.18
by Jelmer Vernooij
Some fixes. |
1560 |
b'success', (b'ok', vfs_url.encode('utf-8'))) |
|
5712.3.17
by Jelmer Vernooij
more fixes. |
1561 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1562 |
_client=client) |
|
4118.1.5
by Andrew Bennetts
Fix test_remote tests. |
1563 |
repo_fmt = remote.RemoteRepositoryFormat() |
1564 |
repo_fmt._custom_format = stacked_branch.repository._format |
|
1565 |
branch = RemoteBranch(bzrdir, RemoteRepository(bzrdir, repo_fmt), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1566 |
_client=client) |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1567 |
result = branch.get_stacked_on_url() |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1568 |
self.assertEqual(vfs_url, result) |
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1569 |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1570 |
def test_backwards_compatible(self): |
1571 |
# like with bzr1.6 with no Branch.get_stacked_on_url rpc
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1572 |
self.make_branch('base', format='1.6') |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1573 |
stacked_branch = self.make_branch('stacked', format='1.6') |
1574 |
stacked_branch.set_stacked_on_url('../base') |
|
1575 |
client = FakeClient(self.get_url()) |
|
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1576 |
branch_network_name = self.get_branch_format().network_name() |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1577 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1578 |
b'BzrDir.open_branchV3', (b'stacked/',), |
1579 |
b'success', (b'branch', branch_network_name)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1580 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1581 |
b'BzrDir.find_repositoryV3', (b'stacked/',), |
1582 |
b'success', (b'ok', b'', b'no', b'no', b'yes', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1583 |
stacked_branch.repository._format.network_name())) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1584 |
# called twice, once from constructor and then again by us
|
1585 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1586 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1587 |
b'unknown', (b'Branch.get_stacked_on_url',)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1588 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1589 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1590 |
b'unknown', (b'Branch.get_stacked_on_url',)) |
|
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1591 |
# this will also do vfs access, but that goes direct to the transport
|
1592 |
# and isn't seen by the FakeClient.
|
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1593 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1594 |
RemoteBzrDirFormat(), _client=client) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1595 |
branch = bzrdir.open_branch() |
1596 |
result = branch.get_stacked_on_url() |
|
1597 |
self.assertEqual('../base', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1598 |
self.assertFinished(client) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1599 |
# it's in the fallback list both for the RemoteRepository and its vfs
|
1600 |
# repository
|
|
1601 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
|
1602 |
self.assertEqual(1, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1603 |
len(branch.repository._real_repository._fallback_repositories)) |
|
3691.2.12
by Martin Pool
Add test for coping without Branch.get_stacked_on_url |
1604 |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1605 |
def test_get_stacked_on_real_branch(self): |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1606 |
self.make_branch('base') |
|
5158.4.3
by Andrew Bennetts
Fix test_remote tests that accidentally assumed it was ok to stack mismatched formats. |
1607 |
stacked_branch = self.make_branch('stacked') |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1608 |
stacked_branch.set_stacked_on_url('../base') |
|
4053.1.2
by Robert Collins
Actually make this branch work. |
1609 |
reference_format = self.get_repo_format() |
1610 |
network_name = reference_format.network_name() |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1611 |
client = FakeClient(self.get_url()) |
|
4084.2.1
by Robert Collins
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects. |
1612 |
branch_network_name = self.get_branch_format().network_name() |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1613 |
client.add_expected_call( |
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
1614 |
b'BzrDir.open_branchV3', (b'stacked/',), |
1615 |
b'success', (b'branch', branch_network_name)) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1616 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1617 |
b'BzrDir.find_repositoryV3', (b'stacked/',), |
1618 |
b'success', (b'ok', b'', b'yes', b'no', b'yes', network_name)) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1619 |
# called twice, once from constructor and then again by us
|
1620 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1621 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1622 |
b'success', (b'ok', b'../base')) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1623 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1624 |
b'Branch.get_stacked_on_url', (b'stacked/',), |
1625 |
b'success', (b'ok', b'../base')) |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1626 |
bzrdir = RemoteBzrDir(self.get_transport('stacked'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1627 |
RemoteBzrDirFormat(), _client=client) |
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1628 |
branch = bzrdir.open_branch() |
1629 |
result = branch.get_stacked_on_url() |
|
1630 |
self.assertEqual('../base', result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1631 |
self.assertFinished(client) |
|
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1632 |
# it's in the fallback list both for the RemoteRepository.
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1633 |
self.assertEqual(1, len(branch.repository._fallback_repositories)) |
|
4226.1.2
by Robert Collins
Fix test_remote failing because of less _real_repository objects. |
1634 |
# And we haven't had to construct a real repository.
|
1635 |
self.assertEqual(None, branch.repository._real_repository) |
|
|
3691.2.11
by Martin Pool
More tests around RemoteBranch stacking. |
1636 |
|
|
3691.2.5
by Martin Pool
Add Branch.get_stacked_on_url rpc and tests for same |
1637 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1638 |
class TestBranchSetLastRevision(RemoteBranchTestCase): |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1639 |
|
1640 |
def test_set_empty(self): |
|
|
5718.7.12
by Jelmer Vernooij
Fix use of _set_last_revision. |
1641 |
# _set_last_revision_info('null:') is translated to calling
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1642 |
# Branch.set_last_revision(path, '') on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1643 |
transport = MemoryTransport() |
1644 |
transport.mkdir('branch') |
|
1645 |
transport = transport.clone('branch') |
|
1646 |
||
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1647 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1648 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1649 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1650 |
b'error', (b'NotStacked',)) |
|
1651 |
client.add_expected_call( |
|
1652 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1653 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1654 |
client.add_expected_call( |
|
1655 |
b'Branch.last_revision_info', |
|
1656 |
(b'branch/',), |
|
1657 |
b'success', (b'ok', b'0', b'null:')) |
|
1658 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1659 |
b'Branch.set_last_revision', (b'branch/', |
1660 |
b'branch token', b'repo token', b'null:',), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1661 |
b'success', (b'ok',)) |
1662 |
client.add_expected_call( |
|
1663 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1664 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1665 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1666 |
branch.lock_write() |
|
5718.7.12
by Jelmer Vernooij
Fix use of _set_last_revision. |
1667 |
result = branch._set_last_revision(NULL_REVISION) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1668 |
branch.unlock() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1669 |
self.assertEqual(None, result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1670 |
self.assertFinished(client) |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1671 |
|
1672 |
def test_set_nonempty(self): |
|
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1673 |
# set_last_revision_info(N, rev-idN) is translated to calling
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1674 |
# Branch.set_last_revision(path, rev-idN) on the wire.
|
|
3104.4.2
by Andrew Bennetts
All tests passing. |
1675 |
transport = MemoryTransport() |
1676 |
transport.mkdir('branch') |
|
1677 |
transport = transport.clone('branch') |
|
1678 |
||
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1679 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1680 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1681 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1682 |
b'error', (b'NotStacked',)) |
|
1683 |
client.add_expected_call( |
|
1684 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1685 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1686 |
client.add_expected_call( |
|
1687 |
b'Branch.last_revision_info', |
|
1688 |
(b'branch/',), |
|
1689 |
b'success', (b'ok', b'0', b'null:')) |
|
1690 |
lines = [b'rev-id2'] |
|
1691 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1692 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1693 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1694 |
b'Branch.set_last_revision', (b'branch/', |
1695 |
b'branch token', b'repo token', b'rev-id2',), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1696 |
b'success', (b'ok',)) |
1697 |
client.add_expected_call( |
|
1698 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1699 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1700 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1701 |
# Lock the branch, reset the record of remote calls.
|
1702 |
branch.lock_write() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1703 |
result = branch._set_last_revision(b'rev-id2') |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1704 |
branch.unlock() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1705 |
self.assertEqual(None, result) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1706 |
self.assertFinished(client) |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1707 |
|
1708 |
def test_no_such_revision(self): |
|
1709 |
transport = MemoryTransport() |
|
1710 |
transport.mkdir('branch') |
|
1711 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1712 |
# A response of 'NoSuchRevision' is translated into an exception.
|
1713 |
client = FakeClient(transport.base) |
|
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
1714 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1715 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1716 |
b'error', (b'NotStacked',)) |
|
1717 |
client.add_expected_call( |
|
1718 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1719 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1720 |
client.add_expected_call( |
|
1721 |
b'Branch.last_revision_info', |
|
1722 |
(b'branch/',), |
|
1723 |
b'success', (b'ok', b'0', b'null:')) |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1724 |
# get_graph calls to construct the revision history, for the set_rh
|
1725 |
# hook
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1726 |
lines = [b'rev-id'] |
1727 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1728 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1729 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1730 |
b'Branch.set_last_revision', (b'branch/', |
1731 |
b'branch token', b'repo token', b'rev-id',), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1732 |
b'error', (b'NoSuchRevision', b'rev-id')) |
1733 |
client.add_expected_call( |
|
1734 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1735 |
b'success', (b'ok',)) |
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1736 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1737 |
branch = self.make_remote_branch(transport, client) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1738 |
branch.lock_write() |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1739 |
self.assertRaises( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1740 |
errors.NoSuchRevision, branch._set_last_revision, b'rev-id') |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1741 |
branch.unlock() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1742 |
self.assertFinished(client) |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1743 |
|
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1744 |
def test_tip_change_rejected(self): |
1745 |
"""TipChangeRejected responses cause a TipChangeRejected exception to |
|
1746 |
be raised.
|
|
1747 |
"""
|
|
1748 |
transport = MemoryTransport() |
|
1749 |
transport.mkdir('branch') |
|
1750 |
transport = transport.clone('branch') |
|
1751 |
client = FakeClient(transport.base) |
|
1752 |
rejection_msg_unicode = u'rejection message\N{INTERROBANG}' |
|
1753 |
rejection_msg_utf8 = rejection_msg_unicode.encode('utf8') |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1754 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1755 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1756 |
b'error', (b'NotStacked',)) |
|
1757 |
client.add_expected_call( |
|
1758 |
b'Branch.lock_write', (b'branch/', b'', b''), |
|
1759 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1760 |
client.add_expected_call( |
|
1761 |
b'Branch.last_revision_info', |
|
1762 |
(b'branch/',), |
|
1763 |
b'success', (b'ok', b'0', b'null:')) |
|
1764 |
lines = [b'rev-id'] |
|
1765 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
1766 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
1767 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1768 |
b'Branch.set_last_revision', (b'branch/', |
1769 |
b'branch token', b'repo token', b'rev-id',), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1770 |
b'error', (b'TipChangeRejected', rejection_msg_utf8)) |
1771 |
client.add_expected_call( |
|
1772 |
b'Branch.unlock', (b'branch/', b'branch token', b'repo token'), |
|
1773 |
b'success', (b'ok',)) |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1774 |
branch = self.make_remote_branch(transport, client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1775 |
branch.lock_write() |
1776 |
# The 'TipChangeRejected' error response triggered by calling
|
|
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1777 |
# set_last_revision_info causes a TipChangeRejected exception.
|
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1778 |
err = self.assertRaises( |
|
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
1779 |
errors.TipChangeRejected, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1780 |
branch._set_last_revision, b'rev-id') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1781 |
# The UTF-8 message from the response has been decoded into a unicode
|
1782 |
# object.
|
|
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
1783 |
self.assertIsInstance(err.msg, str) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1784 |
self.assertEqual(rejection_msg_unicode, err.msg) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1785 |
branch.unlock() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1786 |
self.assertFinished(client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1787 |
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
1788 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1789 |
class TestBranchSetLastRevisionInfo(RemoteBranchTestCase): |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1790 |
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1791 |
def test_set_last_revision_info(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1792 |
# set_last_revision_info(num, b'rev-id') is translated to calling
|
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1793 |
# Branch.set_last_revision_info(num, 'rev-id') on the wire.
|
|
3297.4.1
by Andrew Bennetts
Merge 'Add Branch.set_last_revision_info smart method'. |
1794 |
transport = MemoryTransport() |
1795 |
transport.mkdir('branch') |
|
1796 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1797 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1798 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1799 |
client.add_error_response(b'NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1800 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1801 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1802 |
# query the current revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1803 |
client.add_success_response(b'ok', b'0', b'null:') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1804 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1805 |
client.add_success_response(b'ok') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1806 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1807 |
client.add_success_response(b'ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1808 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1809 |
branch = self.make_remote_branch(transport, client) |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1810 |
# Lock the branch, reset the record of remote calls.
|
1811 |
branch.lock_write() |
|
1812 |
client._calls = [] |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1813 |
result = branch.set_last_revision_info(1234, b'a-revision-id') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1814 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1815 |
[('call', b'Branch.last_revision_info', (b'branch/',)), |
1816 |
('call', b'Branch.set_last_revision_info', |
|
1817 |
(b'branch/', b'branch token', b'repo token', |
|
1818 |
b'1234', b'a-revision-id'))], |
|
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1819 |
client._calls) |
1820 |
self.assertEqual(None, result) |
|
1821 |
||
1822 |
def test_no_such_revision(self): |
|
1823 |
# A response of 'NoSuchRevision' is translated into an exception.
|
|
1824 |
transport = MemoryTransport() |
|
1825 |
transport.mkdir('branch') |
|
1826 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1827 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1828 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1829 |
client.add_error_response(b'NotStacked') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1830 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1831 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1832 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1833 |
client.add_error_response(b'NoSuchRevision', b'revid') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1834 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1835 |
client.add_success_response(b'ok') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1836 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1837 |
branch = self.make_remote_branch(transport, client) |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1838 |
# Lock the branch, reset the record of remote calls.
|
1839 |
branch.lock_write() |
|
1840 |
client._calls = [] |
|
1841 |
||
1842 |
self.assertRaises( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1843 |
errors.NoSuchRevision, branch.set_last_revision_info, 123, b'revid') |
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1844 |
branch.unlock() |
1845 |
||
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1846 |
def test_backwards_compatibility(self): |
1847 |
"""If the server does not support the Branch.set_last_revision_info |
|
1848 |
verb (which is new in 1.4), then the client falls back to VFS methods.
|
|
1849 |
"""
|
|
1850 |
# This test is a little messy. Unlike most tests in this file, it
|
|
1851 |
# doesn't purely test what a Remote* object sends over the wire, and
|
|
1852 |
# how it reacts to responses from the wire. It instead relies partly
|
|
1853 |
# on asserting that the RemoteBranch will call
|
|
1854 |
# self._real_branch.set_last_revision_info(...).
|
|
1855 |
||
1856 |
# First, set up our RemoteBranch with a FakeClient that raises
|
|
1857 |
# UnknownSmartMethod, and a StubRealBranch that logs how it is called.
|
|
1858 |
transport = MemoryTransport() |
|
1859 |
transport.mkdir('branch') |
|
1860 |
transport = transport.clone('branch') |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
1861 |
client = FakeClient(transport.base) |
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1862 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1863 |
b'Branch.get_stacked_on_url', (b'branch/',), |
1864 |
b'error', (b'NotStacked',)) |
|
1865 |
client.add_expected_call( |
|
1866 |
b'Branch.last_revision_info', |
|
1867 |
(b'branch/',), |
|
1868 |
b'success', (b'ok', b'0', b'null:')) |
|
1869 |
client.add_expected_call( |
|
1870 |
b'Branch.set_last_revision_info', |
|
1871 |
(b'branch/', b'branch token', b'repo token', b'1234', b'a-revision-id',), |
|
1872 |
b'unknown', b'Branch.set_last_revision_info') |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1873 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1874 |
branch = self.make_remote_branch(transport, client) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1875 |
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1876 |
class StubRealBranch(object): |
1877 |
def __init__(self): |
|
1878 |
self.calls = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1879 |
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1880 |
def set_last_revision_info(self, revno, revision_id): |
1881 |
self.calls.append( |
|
1882 |
('set_last_revision_info', revno, revision_id)) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1883 |
|
|
3441.5.5
by Andrew Bennetts
Some small tweaks and comments. |
1884 |
def _clear_cached_state(self): |
1885 |
pass
|
|
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1886 |
real_branch = StubRealBranch() |
1887 |
branch._real_branch = real_branch |
|
1888 |
self.lock_remote_branch(branch) |
|
1889 |
||
1890 |
# Call set_last_revision_info, and verify it behaved as expected.
|
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
1891 |
branch.set_last_revision_info(1234, b'a-revision-id') |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1892 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1893 |
[('set_last_revision_info', 1234, b'a-revision-id')], |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1894 |
real_branch.calls) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
1895 |
self.assertFinished(client) |
|
3297.4.2
by Andrew Bennetts
Add backwards compatibility for servers older than 1.4. |
1896 |
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1897 |
def test_unexpected_error(self): |
|
3697.2.6
by Martin Pool
Merge 261315 fix into 1.7 branch |
1898 |
# If the server sends an error the client doesn't understand, it gets
|
1899 |
# turned into an UnknownErrorFromSmartServer, which is presented as a
|
|
1900 |
# non-internal error to the user.
|
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1901 |
transport = MemoryTransport() |
1902 |
transport.mkdir('branch') |
|
1903 |
transport = transport.clone('branch') |
|
1904 |
client = FakeClient(transport.base) |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1905 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1906 |
client.add_error_response(b'NotStacked') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1907 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1908 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1909 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1910 |
client.add_error_response(b'UnexpectedError') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1911 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1912 |
client.add_success_response(b'ok') |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1913 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1914 |
branch = self.make_remote_branch(transport, client) |
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1915 |
# Lock the branch, reset the record of remote calls.
|
1916 |
branch.lock_write() |
|
1917 |
client._calls = [] |
|
1918 |
||
1919 |
err = self.assertRaises( |
|
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
1920 |
errors.UnknownErrorFromSmartServer, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1921 |
branch.set_last_revision_info, 123, b'revid') |
1922 |
self.assertEqual((b'UnexpectedError',), err.error_tuple) |
|
|
3245.4.53
by Andrew Bennetts
Add some missing 'raise' statements to test_remote. |
1923 |
branch.unlock() |
1924 |
||
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1925 |
def test_tip_change_rejected(self): |
1926 |
"""TipChangeRejected responses cause a TipChangeRejected exception to |
|
1927 |
be raised.
|
|
1928 |
"""
|
|
1929 |
transport = MemoryTransport() |
|
1930 |
transport.mkdir('branch') |
|
1931 |
transport = transport.clone('branch') |
|
1932 |
client = FakeClient(transport.base) |
|
|
3691.2.10
by Martin Pool
Update more test_remote tests |
1933 |
# get_stacked_on_url
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1934 |
client.add_error_response(b'NotStacked') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1935 |
# lock_write
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1936 |
client.add_success_response(b'ok', b'branch token', b'repo token') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1937 |
# set_last_revision
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1938 |
client.add_error_response(b'TipChangeRejected', b'rejection message') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1939 |
# unlock
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1940 |
client.add_success_response(b'ok') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1941 |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
1942 |
branch = self.make_remote_branch(transport, client) |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1943 |
# Lock the branch, reset the record of remote calls.
|
1944 |
branch.lock_write() |
|
1945 |
self.addCleanup(branch.unlock) |
|
1946 |
client._calls = [] |
|
1947 |
||
1948 |
# The 'TipChangeRejected' error response triggered by calling
|
|
1949 |
# set_last_revision_info causes a TipChangeRejected exception.
|
|
1950 |
err = self.assertRaises( |
|
1951 |
errors.TipChangeRejected, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1952 |
branch.set_last_revision_info, 123, b'revid') |
|
3577.1.1
by Andrew Bennetts
Cherry-pick TipChangeRejected changes from pre-branch-tip-changed-hook loom. |
1953 |
self.assertEqual('rejection message', err.msg) |
1954 |
||
|
2892.2.1
by Andrew Bennetts
Add Branch.set_last_revision_info smart method, and make the RemoteBranch client use it. |
1955 |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1956 |
class TestBranchGetSetConfig(RemoteBranchTestCase): |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1957 |
|
1958 |
def test_get_branch_conf(self): |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1959 |
# in an empty branch we decode the response properly
|
1960 |
client = FakeClient() |
|
1961 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1962 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1963 |
b'error', (b'NotStacked',),) |
|
1964 |
client.add_success_response_with_body(b'# config file body', b'ok') |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1965 |
transport = MemoryTransport() |
1966 |
branch = self.make_remote_branch(transport, client) |
|
1967 |
config = branch.get_config() |
|
1968 |
config.has_explicit_nickname() |
|
1969 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1970 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
1971 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',))], |
|
|
4226.1.5
by Robert Collins
Reinstate the use of the Branch.get_config_file verb. |
1972 |
client._calls) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
1973 |
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1974 |
def test_get_multi_line_branch_conf(self): |
1975 |
# Make sure that multiple-line branch.conf files are supported
|
|
1976 |
#
|
|
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
1977 |
# https://bugs.launchpad.net/bzr/+bug/354075
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1978 |
client = FakeClient() |
1979 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1980 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1981 |
b'error', (b'NotStacked',),) |
|
1982 |
client.add_success_response_with_body(b'a = 1\nb = 2\nc = 3\n', b'ok') |
|
|
4241.5.2
by Matt Nordhoff
Add a test |
1983 |
transport = MemoryTransport() |
1984 |
branch = self.make_remote_branch(transport, client) |
|
1985 |
config = branch.get_config() |
|
1986 |
self.assertEqual(u'2', config.get_user_option('b')) |
|
1987 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
1988 |
def test_set_option(self): |
1989 |
client = FakeClient() |
|
1990 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1991 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
1992 |
b'error', (b'NotStacked',),) |
|
1993 |
client.add_expected_call( |
|
1994 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
|
1995 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
1996 |
client.add_expected_call( |
|
1997 |
b'Branch.set_config_option', (b'memory:///', b'branch token', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
1998 |
b'repo token', b'foo', b'bar', b''), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
1999 |
b'success', ()) |
2000 |
client.add_expected_call( |
|
2001 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
|
2002 |
b'success', (b'ok',)) |
|
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2003 |
transport = MemoryTransport() |
2004 |
branch = self.make_remote_branch(transport, client) |
|
2005 |
branch.lock_write() |
|
2006 |
config = branch._get_config() |
|
2007 |
config.set_option('foo', 'bar') |
|
2008 |
branch.unlock() |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2009 |
self.assertFinished(client) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2010 |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2011 |
def test_set_option_with_dict(self): |
2012 |
client = FakeClient() |
|
2013 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2014 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
2015 |
b'error', (b'NotStacked',),) |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2016 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2017 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
2018 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
|
7058.4.1
by Jelmer Vernooij
Fix another 40 tests. |
2019 |
encoded_dict_value = b'd5:ascii1:a11:unicode \xe2\x8c\x9a3:\xe2\x80\xbde' |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2020 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2021 |
b'Branch.set_config_option_dict', (b'memory:///', b'branch token', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2022 |
b'repo token', encoded_dict_value, b'foo', b''), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2023 |
b'success', ()) |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2024 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2025 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
2026 |
b'success', (b'ok',)) |
|
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2027 |
transport = MemoryTransport() |
2028 |
branch = self.make_remote_branch(transport, client) |
|
2029 |
branch.lock_write() |
|
2030 |
config = branch._get_config() |
|
2031 |
config.set_option( |
|
2032 |
{'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'}, |
|
2033 |
'foo') |
|
2034 |
branch.unlock() |
|
2035 |
self.assertFinished(client) |
|
2036 |
||
|
7289.1.4
by Jelmer Vernooij
Review comments, test. |
2037 |
def test_set_option_with_bool(self): |
2038 |
client = FakeClient() |
|
2039 |
client.add_expected_call( |
|
2040 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
|
2041 |
b'error', (b'NotStacked',),) |
|
2042 |
client.add_expected_call( |
|
2043 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
|
2044 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
2045 |
client.add_expected_call( |
|
2046 |
b'Branch.set_config_option', (b'memory:///', b'branch token', |
|
2047 |
b'repo token', b'True', b'foo', b''), |
|
2048 |
b'success', ()) |
|
2049 |
client.add_expected_call( |
|
2050 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
|
2051 |
b'success', (b'ok',)) |
|
2052 |
transport = MemoryTransport() |
|
2053 |
branch = self.make_remote_branch(transport, client) |
|
2054 |
branch.lock_write() |
|
2055 |
config = branch._get_config() |
|
2056 |
config.set_option(True, 'foo') |
|
2057 |
branch.unlock() |
|
2058 |
self.assertFinished(client) |
|
2059 |
||
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2060 |
def test_backwards_compat_set_option(self): |
2061 |
self.setup_smart_server_with_call_log() |
|
2062 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2063 |
verb = b'Branch.set_config_option' |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2064 |
self.disable_verb(verb) |
2065 |
branch.lock_write() |
|
2066 |
self.addCleanup(branch.unlock) |
|
2067 |
self.reset_smart_call_log() |
|
2068 |
branch._get_config().set_option('value', 'name') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2069 |
self.assertLength(11, self.hpss_calls) |
|
4226.2.1
by Robert Collins
Set branch config options via a smart method. |
2070 |
self.assertEqual('value', branch._get_config().get_option('name')) |
2071 |
||
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2072 |
def test_backwards_compat_set_option_with_dict(self): |
2073 |
self.setup_smart_server_with_call_log() |
|
2074 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2075 |
verb = b'Branch.set_config_option_dict' |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2076 |
self.disable_verb(verb) |
2077 |
branch.lock_write() |
|
2078 |
self.addCleanup(branch.unlock) |
|
2079 |
self.reset_smart_call_log() |
|
2080 |
config = branch._get_config() |
|
2081 |
value_dict = {'ascii': 'a', u'unicode \N{WATCH}': u'\N{INTERROBANG}'} |
|
2082 |
config.set_option(value_dict, 'name') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2083 |
self.assertLength(11, self.hpss_calls) |
|
5227.1.2
by Andrew Bennetts
Add Branch.set_config_option_dict RPC (and VFS fallback), fixes #430382. |
2084 |
self.assertEqual(value_dict, branch._get_config().get_option('name')) |
2085 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
2086 |
|
|
6270.1.23
by Jelmer Vernooij
Add notes about Remote{Control,Branch}Store. |
2087 |
class TestBranchGetPutConfigStore(RemoteBranchTestCase): |
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2088 |
|
2089 |
def test_get_branch_conf(self): |
|
2090 |
# in an empty branch we decode the response properly
|
|
2091 |
client = FakeClient() |
|
2092 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2093 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
2094 |
b'error', (b'NotStacked',),) |
|
2095 |
client.add_success_response_with_body(b'# config file body', b'ok') |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2096 |
transport = MemoryTransport() |
2097 |
branch = self.make_remote_branch(transport, client) |
|
2098 |
config = branch.get_config_stack() |
|
2099 |
config.get("email") |
|
2100 |
config.get("log_format") |
|
2101 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2102 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
2103 |
('call_expecting_body', b'Branch.get_config_file', (b'memory:///',))], |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2104 |
client._calls) |
2105 |
||
2106 |
def test_set_branch_conf(self): |
|
2107 |
client = FakeClient() |
|
2108 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2109 |
b'Branch.get_stacked_on_url', (b'memory:///',), |
2110 |
b'error', (b'NotStacked',),) |
|
2111 |
client.add_expected_call( |
|
2112 |
b'Branch.lock_write', (b'memory:///', b'', b''), |
|
2113 |
b'success', (b'ok', b'branch token', b'repo token')) |
|
2114 |
client.add_expected_call( |
|
2115 |
b'Branch.get_config_file', (b'memory:///', ), |
|
2116 |
b'success', (b'ok', ), b"# line 1\n") |
|
2117 |
client.add_expected_call( |
|
2118 |
b'Branch.get_config_file', (b'memory:///', ), |
|
2119 |
b'success', (b'ok', ), b"# line 1\n") |
|
2120 |
client.add_expected_call( |
|
2121 |
b'Branch.put_config_file', (b'memory:///', b'branch token', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2122 |
b'repo token'), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2123 |
b'success', (b'ok',)) |
2124 |
client.add_expected_call( |
|
2125 |
b'Branch.unlock', (b'memory:///', b'branch token', b'repo token'), |
|
2126 |
b'success', (b'ok',)) |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2127 |
transport = MemoryTransport() |
2128 |
branch = self.make_remote_branch(transport, client) |
|
2129 |
branch.lock_write() |
|
2130 |
config = branch.get_config_stack() |
|
2131 |
config.set('email', 'The Dude <lebowski@example.com>') |
|
2132 |
branch.unlock() |
|
2133 |
self.assertFinished(client) |
|
2134 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2135 |
[('call', b'Branch.get_stacked_on_url', (b'memory:///',)), |
2136 |
('call', b'Branch.lock_write', (b'memory:///', b'', b'')), |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2137 |
('call_expecting_body', b'Branch.get_config_file', |
2138 |
(b'memory:///',)), |
|
2139 |
('call_expecting_body', b'Branch.get_config_file', |
|
2140 |
(b'memory:///',)), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2141 |
('call_with_body_bytes_expecting_body', b'Branch.put_config_file', |
2142 |
(b'memory:///', b'branch token', b'repo token'), |
|
2143 |
b'# line 1\nemail = The Dude <lebowski@example.com>\n'), |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2144 |
('call', b'Branch.unlock', |
2145 |
(b'memory:///', b'branch token', b'repo token'))], |
|
|
6270.1.10
by Jelmer Vernooij
Fix testing Branch.set_config_file. |
2146 |
client._calls) |
2147 |
||
2148 |
||
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
2149 |
class TestBranchLockWrite(RemoteBranchTestCase): |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2150 |
|
2151 |
def test_lock_write_unlockable(self): |
|
2152 |
transport = MemoryTransport() |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2153 |
client = FakeClient(transport.base) |
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
2154 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2155 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2156 |
b'error', (b'NotStacked',),) |
|
|
3691.2.9
by Martin Pool
Convert and update more test_remote tests |
2157 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2158 |
b'Branch.lock_write', (b'quack/', b'', b''), |
2159 |
b'error', (b'UnlockableTransport',)) |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2160 |
transport.mkdir('quack') |
2161 |
transport = transport.clone('quack') |
|
|
3692.1.1
by Andrew Bennetts
Make RemoteBranch.lock_write lock the repository too. |
2162 |
branch = self.make_remote_branch(transport, client) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2163 |
self.assertRaises(errors.UnlockableTransport, branch.lock_write) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2164 |
self.assertFinished(client) |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
2165 |
|
2166 |
||
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2167 |
class TestBranchRevisionIdToRevno(RemoteBranchTestCase): |
2168 |
||
2169 |
def test_simple(self): |
|
2170 |
transport = MemoryTransport() |
|
2171 |
client = FakeClient(transport.base) |
|
2172 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2173 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2174 |
b'error', (b'NotStacked',),) |
|
2175 |
client.add_expected_call( |
|
2176 |
b'Branch.revision_id_to_revno', (b'quack/', b'null:'), |
|
2177 |
b'success', (b'ok', b'0',),) |
|
2178 |
client.add_expected_call( |
|
2179 |
b'Branch.revision_id_to_revno', (b'quack/', b'unknown'), |
|
2180 |
b'error', (b'NoSuchRevision', b'unknown',),) |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2181 |
transport.mkdir('quack') |
2182 |
transport = transport.clone('quack') |
|
2183 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2184 |
self.assertEqual(0, branch.revision_id_to_revno(b'null:')) |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2185 |
self.assertRaises(errors.NoSuchRevision, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2186 |
branch.revision_id_to_revno, b'unknown') |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2187 |
self.assertFinished(client) |
2188 |
||
2189 |
def test_dotted(self): |
|
2190 |
transport = MemoryTransport() |
|
2191 |
client = FakeClient(transport.base) |
|
2192 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2193 |
b'Branch.get_stacked_on_url', (b'quack/',), |
2194 |
b'error', (b'NotStacked',),) |
|
2195 |
client.add_expected_call( |
|
2196 |
b'Branch.revision_id_to_revno', (b'quack/', b'null:'), |
|
2197 |
b'success', (b'ok', b'0',),) |
|
2198 |
client.add_expected_call( |
|
2199 |
b'Branch.revision_id_to_revno', (b'quack/', b'unknown'), |
|
2200 |
b'error', (b'NoSuchRevision', b'unknown',),) |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2201 |
transport.mkdir('quack') |
2202 |
transport = transport.clone('quack') |
|
2203 |
branch = self.make_remote_branch(transport, client) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2204 |
self.assertEqual((0, ), branch.revision_id_to_dotted_revno(b'null:')) |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2205 |
self.assertRaises(errors.NoSuchRevision, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2206 |
branch.revision_id_to_dotted_revno, b'unknown') |
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2207 |
self.assertFinished(client) |
2208 |
||
|
7290.20.2
by Jelmer Vernooij
Handle GhostRevisionsHaveNoRevno. |
2209 |
def test_ghost_revid(self): |
2210 |
transport = MemoryTransport() |
|
2211 |
client = FakeClient(transport.base) |
|
2212 |
client.add_expected_call( |
|
2213 |
b'Branch.get_stacked_on_url', (b'quack/',), |
|
2214 |
b'error', (b'NotStacked',),) |
|
2215 |
# Some older versions of bzr/brz didn't explicitly return
|
|
2216 |
# GhostRevisionsHaveNoRevno
|
|
2217 |
client.add_expected_call( |
|
2218 |
b'Branch.revision_id_to_revno', (b'quack/', b'revid'), |
|
2219 |
b'error', (b'error', b'GhostRevisionsHaveNoRevno', |
|
|
7290.20.4
by Jelmer Vernooij
Fix formatting. |
2220 |
b'The reivison {revid} was not found because there was ' |
2221 |
b'a ghost at {ghost-revid}')) |
|
|
7290.20.2
by Jelmer Vernooij
Handle GhostRevisionsHaveNoRevno. |
2222 |
client.add_expected_call( |
2223 |
b'Branch.revision_id_to_revno', (b'quack/', b'revid'), |
|
2224 |
b'error', (b'GhostRevisionsHaveNoRevno', b'revid', b'ghost-revid',)) |
|
2225 |
transport.mkdir('quack') |
|
2226 |
transport = transport.clone('quack') |
|
2227 |
branch = self.make_remote_branch(transport, client) |
|
2228 |
self.assertRaises(errors.GhostRevisionsHaveNoRevno, |
|
2229 |
branch.revision_id_to_dotted_revno, b'revid') |
|
2230 |
self.assertRaises(errors.GhostRevisionsHaveNoRevno, |
|
2231 |
branch.revision_id_to_dotted_revno, b'revid') |
|
2232 |
self.assertFinished(client) |
|
2233 |
||
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2234 |
def test_dotted_no_smart_verb(self): |
2235 |
self.setup_smart_server_with_call_log() |
|
2236 |
branch = self.make_branch('.') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2237 |
self.disable_verb(b'Branch.revision_id_to_revno') |
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2238 |
self.reset_smart_call_log() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2239 |
self.assertEqual((0, ), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2240 |
branch.revision_id_to_dotted_revno(b'null:')) |
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2241 |
self.assertLength(8, self.hpss_calls) |
|
6305.1.1
by Jelmer Vernooij
Add test for Branch.revision_id_to_dotted_revno fallback. |
2242 |
|
|
6263.1.3
by Jelmer Vernooij
Add dotted revno test. |
2243 |
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2244 |
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase): |
2245 |
||
2246 |
def test__get_config(self): |
|
2247 |
client = FakeClient() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2248 |
client.add_success_response_with_body(b'default_stack_on = /\n', b'ok') |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2249 |
transport = MemoryTransport() |
2250 |
bzrdir = self.make_remote_bzrdir(transport, client) |
|
2251 |
config = bzrdir.get_config() |
|
2252 |
self.assertEqual('/', config.get_default_stack_on()) |
|
2253 |
self.assertEqual( |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2254 |
[('call_expecting_body', b'BzrDir.get_config_file', |
2255 |
(b'memory:///',))], |
|
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2256 |
client._calls) |
2257 |
||
2258 |
def test_set_option_uses_vfs(self): |
|
2259 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
2260 |
bzrdir = self.make_controldir('.') |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2261 |
self.reset_smart_call_log() |
2262 |
config = bzrdir.get_config() |
|
2263 |
config.set_default_stack_on('/') |
|
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2264 |
self.assertLength(4, self.hpss_calls) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2265 |
|
2266 |
def test_backwards_compat_get_option(self): |
|
2267 |
self.setup_smart_server_with_call_log() |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
2268 |
bzrdir = self.make_controldir('.') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2269 |
verb = b'BzrDir.get_config_file' |
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
2270 |
self.disable_verb(verb) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2271 |
self.reset_smart_call_log() |
2272 |
self.assertEqual(None, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2273 |
bzrdir._get_config().get_option('default_stack_on')) |
|
6213.1.61
by Jelmer Vernooij
Fix tests. |
2274 |
self.assertLength(4, self.hpss_calls) |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
2275 |
|
2276 |
||
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2277 |
class TestTransportIsReadonly(tests.TestCase): |
2278 |
||
2279 |
def test_true(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2280 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2281 |
client.add_success_response(b'yes') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2282 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2283 |
_client=client) |
|
2284 |
self.assertEqual(True, transport.is_readonly()) |
|
2285 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2286 |
[('call', b'Transport.is_readonly', ())], |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2287 |
client._calls) |
2288 |
||
2289 |
def test_false(self): |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2290 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2291 |
client.add_success_response(b'no') |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2292 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2293 |
_client=client) |
|
2294 |
self.assertEqual(False, transport.is_readonly()) |
|
2295 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2296 |
[('call', b'Transport.is_readonly', ())], |
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2297 |
client._calls) |
2298 |
||
2299 |
def test_error_from_old_server(self): |
|
2300 |
"""bzr 0.15 and earlier servers don't recognise the is_readonly verb. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2301 |
|
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2302 |
Clients should treat it as a "no" response, because is_readonly is only
|
2303 |
advisory anyway (a transport could be read-write, but then the
|
|
2304 |
underlying filesystem could be readonly anyway).
|
|
2305 |
"""
|
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2306 |
client = FakeClient() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2307 |
client.add_unknown_method_response(b'Transport.is_readonly') |
|
2471.2.1
by Andrew Bennetts
Fix trivial incompatibility with bzr 0.11 servers, which give a slightly different error to bzr 0.15 servers. |
2308 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2309 |
_client=client) |
|
2310 |
self.assertEqual(False, transport.is_readonly()) |
|
2311 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2312 |
[('call', b'Transport.is_readonly', ())], |
|
2471.2.1
by Andrew Bennetts
Fix trivial incompatibility with bzr 0.11 servers, which give a slightly different error to bzr 0.15 servers. |
2313 |
client._calls) |
2314 |
||
|
2466.2.2
by Andrew Bennetts
Add tests for RemoteTransport.is_readonly in the style of the other remote object tests. |
2315 |
|
|
3840.1.1
by Andrew Bennetts
Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error. |
2316 |
class TestTransportMkdir(tests.TestCase): |
2317 |
||
2318 |
def test_permissiondenied(self): |
|
2319 |
client = FakeClient() |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2320 |
client.add_error_response( |
2321 |
b'PermissionDenied', b'remote path', b'extra') |
|
|
3840.1.1
by Andrew Bennetts
Fix RemoteTransport's translation of errors involving paths; it wasn't passing orig_path to _translate_error. |
2322 |
transport = RemoteTransport('bzr://example.com/', medium=False, |
2323 |
_client=client) |
|
2324 |
exc = self.assertRaises( |
|
2325 |
errors.PermissionDenied, transport.mkdir, 'client path') |
|
2326 |
expected_error = errors.PermissionDenied('/client path', 'extra') |
|
2327 |
self.assertEqual(expected_error, exc) |
|
2328 |
||
2329 |
||
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2330 |
class TestRemoteSSHTransportAuthentication(tests.TestCaseInTempDir): |
2331 |
||
|
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
2332 |
def test_defaults_to_none(self): |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2333 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
|
4304.2.1
by Vincent Ladeuil
Fix bug #367726 by reverting some default user handling introduced |
2334 |
self.assertIs(None, t._get_credentials()[0]) |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2335 |
|
2336 |
def test_uses_authentication_config(self): |
|
2337 |
conf = config.AuthenticationConfig() |
|
2338 |
conf._get_config().update( |
|
2339 |
{'bzr+sshtest': {'scheme': 'ssh', 'user': 'bar', 'host': |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2340 |
'example.com'}}) |
|
3777.1.3
by Aaron Bentley
Use SSH default username from authentication.conf |
2341 |
conf._save() |
2342 |
t = RemoteSSHTransport('bzr+ssh://example.com') |
|
2343 |
self.assertEqual('bar', t._get_credentials()[0]) |
|
2344 |
||
2345 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
2346 |
class TestRemoteRepository(TestRemote): |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2347 |
"""Base for testing RemoteRepository protocol usage. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2348 |
|
2349 |
These tests contain frozen requests and responses. We want any changes to
|
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
2350 |
what is sent or expected to be require a thoughtful update to these tests
|
2351 |
because they might break compatibility with different-versioned servers.
|
|
2352 |
"""
|
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2353 |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2354 |
def setup_fake_client_and_repository(self, transport_path): |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2355 |
"""Create the fake client and repository for testing with. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2356 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2357 |
There's no real server here; we just have canned responses sent
|
2358 |
back one by one.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2359 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
2360 |
:param transport_path: Path below the root of the MemoryTransport
|
2361 |
where the repository will be created.
|
|
2362 |
"""
|
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2363 |
transport = MemoryTransport() |
2364 |
transport.mkdir(transport_path) |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2365 |
client = FakeClient(transport.base) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2366 |
transport = transport.clone(transport_path) |
2367 |
# we do not want bzrdir to make any remote calls
|
|
|
5712.3.17
by Jelmer Vernooij
more fixes. |
2368 |
bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2369 |
_client=False) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
2370 |
repo = RemoteRepository(bzrdir, None, _client=client) |
2371 |
return repo, client |
|
2372 |
||
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
2373 |
|
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2374 |
def remoted_description(format): |
2375 |
return 'Remote: ' + format.get_format_description() |
|
2376 |
||
2377 |
||
2378 |
class TestBranchFormat(tests.TestCase): |
|
2379 |
||
2380 |
def test_get_format_description(self): |
|
2381 |
remote_format = RemoteBranchFormat() |
|
|
5662.2.2
by Jelmer Vernooij
Move most format registration functions to BranchFormatRegistry. |
2382 |
real_format = branch.format_registry.get_default() |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2383 |
remote_format._network_name = real_format.network_name() |
2384 |
self.assertEqual(remoted_description(real_format), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2385 |
remote_format.get_format_description()) |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2386 |
|
2387 |
||
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2388 |
class TestRepositoryFormat(TestRemoteRepository): |
2389 |
||
2390 |
def test_fast_delta(self): |
|
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
2391 |
true_name = groupcompress_repo.RepositoryFormat2a().network_name() |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2392 |
true_format = RemoteRepositoryFormat() |
2393 |
true_format._network_name = true_name |
|
2394 |
self.assertEqual(True, true_format.fast_deltas) |
|
|
5757.1.7
by Jelmer Vernooij
Fix more imports. |
2395 |
false_name = knitpack_repo.RepositoryFormatKnitPack1().network_name() |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2396 |
false_format = RemoteRepositoryFormat() |
2397 |
false_format._network_name = false_name |
|
2398 |
self.assertEqual(False, false_format.fast_deltas) |
|
2399 |
||
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2400 |
def test_get_format_description(self): |
2401 |
remote_repo_format = RemoteRepositoryFormat() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
2402 |
real_format = repository.format_registry.get_default() |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2403 |
remote_repo_format._network_name = real_format.network_name() |
2404 |
self.assertEqual(remoted_description(real_format), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2405 |
remote_repo_format.get_format_description()) |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2406 |
|
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
2407 |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2408 |
class TestRepositoryAllRevisionIds(TestRemoteRepository): |
2409 |
||
2410 |
def test_empty(self): |
|
2411 |
transport_path = 'quack' |
|
2412 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2413 |
client.add_success_response_with_body(b'', b'ok') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2414 |
self.assertEqual([], repo.all_revision_ids()) |
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2415 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2416 |
[('call_expecting_body', b'Repository.all_revision_ids', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2417 |
(b'quack/',))], |
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2418 |
client._calls) |
2419 |
||
2420 |
def test_with_some_content(self): |
|
2421 |
transport_path = 'quack' |
|
2422 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2423 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2424 |
b'rev1\nrev2\nanotherrev\n', b'ok') |
|
6973.7.10
by Jelmer Vernooij
More fixes. |
2425 |
self.assertEqual( |
2426 |
set([b"rev1", b"rev2", b"anotherrev"]), |
|
2427 |
set(repo.all_revision_ids())) |
|
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2428 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2429 |
[('call_expecting_body', b'Repository.all_revision_ids', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2430 |
(b'quack/',))], |
|
6280.3.1
by Jelmer Vernooij
Add remote side of Repository.all_revision_ids. |
2431 |
client._calls) |
2432 |
||
2433 |
||
|
2018.12.2
by Andrew Bennetts
Remove some duplicate code in test_remote |
2434 |
class TestRepositoryGatherStats(TestRemoteRepository): |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2435 |
|
2436 |
def test_revid_none(self): |
|
2437 |
# ('ok',), body with revisions and size
|
|
2438 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2439 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
2440 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2441 |
b'revisions: 2\nsize: 18\n', b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2442 |
result = repo.gather_stats(None) |
2443 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2444 |
[('call_expecting_body', b'Repository.gather_stats', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2445 |
(b'quack/', b'', b'no'))], |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2446 |
client._calls) |
2447 |
self.assertEqual({'revisions': 2, 'size': 18}, result) |
|
2448 |
||
2449 |
def test_revid_no_committers(self): |
|
2450 |
# ('ok',), body without committers
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2451 |
body = (b'firstrev: 123456.300 3600\n' |
2452 |
b'latestrev: 654231.400 0\n' |
|
2453 |
b'revisions: 2\n' |
|
2454 |
b'size: 18\n') |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2455 |
transport_path = 'quick' |
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
2456 |
revid = u'\xc8'.encode('utf8') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2457 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2458 |
client.add_success_response_with_body(body, b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2459 |
result = repo.gather_stats(revid) |
2460 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2461 |
[('call_expecting_body', b'Repository.gather_stats', |
2462 |
(b'quick/', revid, b'no'))], |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2463 |
client._calls) |
2464 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
2465 |
'firstrev': (123456.300, 3600), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2466 |
'latestrev': (654231.400, 0), }, |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2467 |
result) |
2468 |
||
2469 |
def test_revid_with_committers(self): |
|
2470 |
# ('ok',), body with committers
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2471 |
body = (b'committers: 128\n' |
2472 |
b'firstrev: 123456.300 3600\n' |
|
2473 |
b'latestrev: 654231.400 0\n' |
|
2474 |
b'revisions: 2\n' |
|
2475 |
b'size: 18\n') |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2476 |
transport_path = 'buick' |
|
2018.5.106
by Andrew Bennetts
Update tests in test_remote to use utf-8 byte strings for revision IDs, rather than unicode strings. |
2477 |
revid = u'\xc8'.encode('utf8') |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2478 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2479 |
client.add_success_response_with_body(body, b'ok') |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2480 |
result = repo.gather_stats(revid, True) |
2481 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2482 |
[('call_expecting_body', b'Repository.gather_stats', |
2483 |
(b'buick/', revid, b'yes'))], |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2484 |
client._calls) |
2485 |
self.assertEqual({'revisions': 2, 'size': 18, |
|
2486 |
'committers': 128, |
|
2487 |
'firstrev': (123456.300, 3600), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2488 |
'latestrev': (654231.400, 0), }, |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
2489 |
result) |
2490 |
||
2491 |
||
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2492 |
class TestRepositoryBreakLock(TestRemoteRepository): |
2493 |
||
2494 |
def test_break_lock(self): |
|
2495 |
transport_path = 'quack' |
|
2496 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2497 |
client.add_success_response(b'ok') |
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2498 |
repo.break_lock() |
2499 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2500 |
[('call', b'Repository.break_lock', (b'quack/',))], |
|
6280.4.1
by Jelmer Vernooij
Add remote side of Repository.break_lock. |
2501 |
client._calls) |
2502 |
||
2503 |
||
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2504 |
class TestRepositoryGetSerializerFormat(TestRemoteRepository): |
2505 |
||
2506 |
def test_get_serializer_format(self): |
|
2507 |
transport_path = 'hill' |
|
2508 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2509 |
client.add_success_response(b'ok', b'7') |
2510 |
self.assertEqual(b'7', repo.get_serializer_format()) |
|
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2511 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2512 |
[('call', b'VersionedFileRepository.get_serializer_format', |
2513 |
(b'hill/', ))], |
|
|
6280.5.1
by Jelmer Vernooij
Add client side of Repository.get_serializer_format. |
2514 |
client._calls) |
2515 |
||
2516 |
||
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2517 |
class TestRepositoryReconcile(TestRemoteRepository): |
2518 |
||
2519 |
def test_reconcile(self): |
|
2520 |
transport_path = 'hill' |
|
2521 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2522 |
body = (b"garbage_inventories: 2\n" |
2523 |
b"inconsistent_parents: 3\n") |
|
|
6300.1.7
by Jelmer Vernooij
Fix test. |
2524 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2525 |
b'Repository.lock_write', (b'hill/', b''), |
2526 |
b'success', (b'ok', b'a token')) |
|
2527 |
client.add_success_response_with_body(body, b'ok') |
|
|
6300.1.4
by Jelmer Vernooij
Add reconcile results. |
2528 |
reconciler = repo.reconcile() |
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2529 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2530 |
[('call', b'Repository.lock_write', (b'hill/', b'')), |
2531 |
('call_expecting_body', b'Repository.reconcile', |
|
2532 |
(b'hill/', b'a token'))], |
|
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2533 |
client._calls) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2534 |
self.assertEqual(2, reconciler.garbage_inventories) |
2535 |
self.assertEqual(3, reconciler.inconsistent_parents) |
|
|
6300.1.1
by Jelmer Vernooij
Add remote implementation of RemoteRepository.reconcile. |
2536 |
|
2537 |
||
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2538 |
class TestRepositoryGetRevisionSignatureText(TestRemoteRepository): |
2539 |
||
2540 |
def test_text(self): |
|
2541 |
# ('ok',), body with signature text
|
|
2542 |
transport_path = 'quack' |
|
2543 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2544 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2545 |
b'THETEXT', b'ok') |
2546 |
self.assertEqual(b"THETEXT", repo.get_signature_text(b"revid")) |
|
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2547 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2548 |
[('call_expecting_body', b'Repository.get_revision_signature_text', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2549 |
(b'quack/', b'revid'))], |
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2550 |
client._calls) |
2551 |
||
2552 |
def test_no_signature(self): |
|
2553 |
transport_path = 'quick' |
|
2554 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2555 |
client.add_error_response(b'nosuchrevision', b'unknown') |
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2556 |
self.assertRaises(errors.NoSuchRevision, repo.get_signature_text, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2557 |
b"unknown") |
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2558 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2559 |
[('call_expecting_body', b'Repository.get_revision_signature_text', |
2560 |
(b'quick/', b'unknown'))], |
|
|
6263.3.2
by Jelmer Vernooij
Add new HPSS call 'Repository.get_revision_signature_text'. |
2561 |
client._calls) |
2562 |
||
2563 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2564 |
class TestRepositoryGetGraph(TestRemoteRepository): |
2565 |
||
2566 |
def test_get_graph(self): |
|
|
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
2567 |
# get_graph returns a graph with a custom parents provider.
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2568 |
transport_path = 'quack' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2569 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2570 |
graph = repo.get_graph() |
|
3835.1.6
by Aaron Bentley
Reduce inefficiency when doing make_parents_provider frequently |
2571 |
self.assertNotEqual(graph._parents_provider, repo) |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2572 |
|
2573 |
||
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2574 |
class TestRepositoryAddSignatureText(TestRemoteRepository): |
2575 |
||
2576 |
def test_add_signature_text(self): |
|
2577 |
transport_path = 'quack' |
|
2578 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2579 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2580 |
b'Repository.lock_write', (b'quack/', b''), |
2581 |
b'success', (b'ok', b'a token')) |
|
2582 |
client.add_expected_call( |
|
2583 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
2584 |
b'success', (b'ok', (b'token1', ))) |
|
2585 |
client.add_expected_call( |
|
2586 |
b'Repository.add_signature_text', (b'quack/', b'a token', b'rev1', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2587 |
b'token1'), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2588 |
b'success', (b'ok', ), None) |
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2589 |
repo.lock_write() |
2590 |
repo.start_write_group() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2591 |
self.assertIs( |
2592 |
None, repo.add_signature_text(b"rev1", b"every bloody emperor")) |
|
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2593 |
self.assertEqual( |
|
6280.10.39
by Jelmer Vernooij
Merge bzr.dev. |
2594 |
('call_with_body_bytes_expecting_body', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2595 |
b'Repository.add_signature_text', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2596 |
(b'quack/', b'a token', b'rev1', b'token1'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2597 |
b'every bloody emperor'), |
|
6280.10.32
by Jelmer Vernooij
Merge bzr.dev. |
2598 |
client._calls[-1]) |
|
6268.1.2
by Jelmer Vernooij
Initial work on Repository.add_signature_text. |
2599 |
|
2600 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2601 |
class TestRepositoryGetParentMap(TestRemoteRepository): |
2602 |
||
2603 |
def test_get_parent_map_caching(self): |
|
2604 |
# get_parent_map returns from cache until unlock()
|
|
2605 |
# setup a reponse with two revisions
|
|
2606 |
r1 = u'\u0e33'.encode('utf8') |
|
2607 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2608 |
lines = [b' '.join([r2, r1]), r1] |
2609 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2610 |
|
2611 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2612 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2613 |
client.add_success_response_with_body(encoded_body, b'ok') |
2614 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2615 |
repo.lock_read() |
2616 |
graph = repo.get_graph() |
|
2617 |
parents = graph.get_parent_map([r2]) |
|
2618 |
self.assertEqual({r2: (r1,)}, parents) |
|
2619 |
# locking and unlocking deeper should not reset
|
|
2620 |
repo.lock_read() |
|
2621 |
repo.unlock() |
|
2622 |
parents = graph.get_parent_map([r1]) |
|
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
2623 |
self.assertEqual({r1: (NULL_REVISION,)}, parents) |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2624 |
self.assertEqual( |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
2625 |
[('call_with_body_bytes_expecting_body', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2626 |
b'Repository.get_parent_map', (b'quack/', |
2627 |
b'include-missing:', r2), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2628 |
b'\n\n0')], |
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2629 |
client._calls) |
2630 |
repo.unlock() |
|
2631 |
# now we call again, and it should use the second response.
|
|
2632 |
repo.lock_read() |
|
2633 |
graph = repo.get_graph() |
|
|
3172.5.6
by Robert Collins
Create new smart server verb Repository.get_parent_map. |
2634 |
parents = graph.get_parent_map([r1]) |
2635 |
self.assertEqual({r1: (NULL_REVISION,)}, parents) |
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2636 |
self.assertEqual( |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
2637 |
[('call_with_body_bytes_expecting_body', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2638 |
b'Repository.get_parent_map', (b'quack/', |
2639 |
b'include-missing:', r2), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2640 |
b'\n\n0'), |
|
3211.5.1
by Robert Collins
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates. |
2641 |
('call_with_body_bytes_expecting_body', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2642 |
b'Repository.get_parent_map', (b'quack/', |
2643 |
b'include-missing:', r1), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2644 |
b'\n\n0'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2645 |
],
|
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2646 |
client._calls) |
2647 |
repo.unlock() |
|
2648 |
||
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2649 |
def test_get_parent_map_reconnects_if_unknown_method(self): |
2650 |
transport_path = 'quack' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2651 |
rev_id = b'revision-id' |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2652 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2653 |
client.add_unknown_method_response(b'Repository.get_parent_map') |
2654 |
client.add_success_response_with_body(rev_id, b'ok') |
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
2655 |
self.assertFalse(client._medium._is_remote_before((1, 2))) |
|
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
2656 |
parents = repo.get_parent_map([rev_id]) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2657 |
self.assertEqual( |
|
3213.1.8
by Andrew Bennetts
Merge from bzr.dev. |
2658 |
[('call_with_body_bytes_expecting_body', |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2659 |
b'Repository.get_parent_map', |
2660 |
(b'quack/', b'include-missing:', rev_id), b'\n\n0'), |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2661 |
('disconnect medium',), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2662 |
('call_expecting_body', b'Repository.get_revision_graph', |
2663 |
(b'quack/', b''))], |
|
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2664 |
client._calls) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2665 |
# The medium is now marked as being connected to an older server
|
|
3453.4.10
by Andrew Bennetts
Change _is_remote_at_least to _is_remote_before. |
2666 |
self.assertTrue(client._medium._is_remote_before((1, 2))) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2667 |
self.assertEqual({rev_id: (b'null:',)}, parents) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2668 |
|
2669 |
def test_get_parent_map_fallback_parentless_node(self): |
|
2670 |
"""get_parent_map falls back to get_revision_graph on old servers. The |
|
2671 |
results from get_revision_graph are tweaked to match the get_parent_map
|
|
2672 |
API.
|
|
2673 |
||
|
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
2674 |
Specifically, a {key: ()} result from get_revision_graph means "no
|
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2675 |
parents" for that key, which in get_parent_map results should be
|
|
3389.1.3
by Andrew Bennetts
Remove XXX from test description. |
2676 |
represented as {key: ('null:',)}.
|
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2677 |
|
2678 |
This is the test for https://bugs.launchpad.net/bzr/+bug/214894
|
|
2679 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2680 |
rev_id = b'revision-id' |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2681 |
transport_path = 'quack' |
|
3245.4.40
by Andrew Bennetts
Merge from bzr.dev. |
2682 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2683 |
client.add_success_response_with_body(rev_id, b'ok') |
|
3453.4.9
by Andrew Bennetts
Rename _remote_is_not to _remember_remote_is_before. |
2684 |
client._medium._remember_remote_is_before((1, 2)) |
|
3948.3.7
by Martin Pool
Updated tests for RemoteRepository.get_parent_map on old servers. |
2685 |
parents = repo.get_parent_map([rev_id]) |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2686 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2687 |
[('call_expecting_body', b'Repository.get_revision_graph', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2688 |
(b'quack/', b''))], |
|
3389.1.2
by Andrew Bennetts
Add test for the bug John found. |
2689 |
client._calls) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2690 |
self.assertEqual({rev_id: (b'null:',)}, parents) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2691 |
|
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
2692 |
def test_get_parent_map_unexpected_response(self): |
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
2693 |
repo, client = self.setup_fake_client_and_repository('path') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2694 |
client.add_success_response(b'something unexpected!') |
|
3297.2.3
by Andrew Bennetts
Test the code path that the typo is on. |
2695 |
self.assertRaises( |
2696 |
errors.UnexpectedSmartServerResponse, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2697 |
repo.get_parent_map, [b'a-revision-id']) |
|
3213.1.2
by Andrew Bennetts
Add test for reconnection if get_parent_map is unknown by the server. |
2698 |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2699 |
def test_get_parent_map_negative_caches_missing_keys(self): |
2700 |
self.setup_smart_server_with_call_log() |
|
2701 |
repo = self.make_repository('foo') |
|
2702 |
self.assertIsInstance(repo, RemoteRepository) |
|
2703 |
repo.lock_read() |
|
2704 |
self.addCleanup(repo.unlock) |
|
2705 |
self.reset_smart_call_log() |
|
2706 |
graph = repo.get_graph() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2707 |
self.assertEqual( |
2708 |
{}, graph.get_parent_map([b'some-missing', b'other-missing'])) |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2709 |
self.assertLength(1, self.hpss_calls) |
2710 |
# No call if we repeat this
|
|
2711 |
self.reset_smart_call_log() |
|
2712 |
graph = repo.get_graph() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2713 |
self.assertEqual( |
2714 |
{}, graph.get_parent_map([b'some-missing', b'other-missing'])) |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2715 |
self.assertLength(0, self.hpss_calls) |
2716 |
# Asking for more unknown keys makes a request.
|
|
2717 |
self.reset_smart_call_log() |
|
2718 |
graph = repo.get_graph() |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2719 |
self.assertEqual( |
2720 |
{}, graph.get_parent_map([b'some-missing', b'other-missing', |
|
2721 |
b'more-missing'])) |
|
|
4190.1.1
by Robert Collins
Negatively cache misses during read-locks in RemoteRepository. |
2722 |
self.assertLength(1, self.hpss_calls) |
2723 |
||
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2724 |
def disableExtraResults(self): |
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
2725 |
self.overrideAttr(SmartServerRepositoryGetParentMap, |
2726 |
'no_extra_results', True) |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2727 |
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2728 |
def test_null_cached_missing_and_stop_key(self): |
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2729 |
self.setup_smart_server_with_call_log() |
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2730 |
# Make a branch with a single revision.
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2731 |
builder = self.make_branch_builder('foo') |
2732 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
2733 |
builder.build_snapshot(None, [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2734 |
('add', ('', b'root-id', 'directory', ''))], |
2735 |
revision_id=b'first') |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2736 |
builder.finish_series() |
2737 |
branch = builder.get_branch() |
|
2738 |
repo = branch.repository |
|
2739 |
self.assertIsInstance(repo, RemoteRepository) |
|
|
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2740 |
# Stop the server from sending extra results.
|
2741 |
self.disableExtraResults() |
|
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2742 |
repo.lock_read() |
2743 |
self.addCleanup(repo.unlock) |
|
2744 |
self.reset_smart_call_log() |
|
2745 |
graph = repo.get_graph() |
|
|
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
2746 |
# Query for b'first' and b'null:'. Because b'null:' is a parent of
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2747 |
# 'first' it will be a candidate for the stop_keys of subsequent
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2748 |
# requests, and because b'null:' was queried but not returned it will
|
2749 |
# be cached as missing.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2750 |
self.assertEqual({b'first': (b'null:',)}, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2751 |
graph.get_parent_map([b'first', b'null:'])) |
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2752 |
# Now query for another key. This request will pass along a recipe of
|
2753 |
# start and stop keys describing the already cached results, and this
|
|
|
4214.2.5
by Andrew Bennetts
Fix the bug. |
2754 |
# recipe's revision count must be correct (or else it will trigger an
|
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2755 |
# error from the server).
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2756 |
self.assertEqual({}, graph.get_parent_map([b'another-key'])) |
|
4214.2.3
by Andrew Bennetts
Further simplify test case, and add more comments. |
2757 |
# This assertion guards against disableExtraResults silently failing to
|
2758 |
# work, thus invalidating the test.
|
|
|
4214.2.4
by Andrew Bennetts
Further simplify the test to reproduce the bug. |
2759 |
self.assertLength(2, self.hpss_calls) |
|
4214.2.1
by Andrew Bennetts
A long but failing test for the get_parent_map RPC bug. |
2760 |
|
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2761 |
def test_get_parent_map_gets_ghosts_from_result(self): |
2762 |
# asking for a revision should negatively cache close ghosts in its
|
|
2763 |
# ancestry.
|
|
2764 |
self.setup_smart_server_with_call_log() |
|
2765 |
tree = self.make_branch_and_memory_tree('foo') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2766 |
with tree.lock_write(): |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2767 |
builder = treebuilder.TreeBuilder() |
2768 |
builder.start_tree(tree) |
|
2769 |
builder.build([]) |
|
2770 |
builder.finish_tree() |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2771 |
tree.set_parent_ids([b'non-existant'], |
2772 |
allow_leftmost_as_ghost=True) |
|
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2773 |
rev_id = tree.commit('') |
2774 |
tree.lock_read() |
|
2775 |
self.addCleanup(tree.unlock) |
|
2776 |
repo = tree.branch.repository |
|
2777 |
self.assertIsInstance(repo, RemoteRepository) |
|
2778 |
# ask for rev_id
|
|
2779 |
repo.get_parent_map([rev_id]) |
|
2780 |
self.reset_smart_call_log() |
|
2781 |
# Now asking for rev_id's ghost parent should not make calls
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2782 |
self.assertEqual({}, repo.get_parent_map([b'non-existant'])) |
|
4190.1.4
by Robert Collins
Cache ghosts when we can get them from a RemoteRepository in get_parent_map. |
2783 |
self.assertLength(0, self.hpss_calls) |
2784 |
||
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2785 |
def test_exposes_get_cached_parent_map(self): |
2786 |
"""RemoteRepository exposes get_cached_parent_map from |
|
2787 |
_unstacked_provider
|
|
2788 |
"""
|
|
2789 |
r1 = u'\u0e33'.encode('utf8') |
|
2790 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2791 |
lines = [b' '.join([r2, r1]), r1] |
2792 |
encoded_body = bz2.compress(b'\n'.join(lines)) |
|
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2793 |
|
2794 |
transport_path = 'quack' |
|
2795 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2796 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2797 |
repo.lock_read() |
|
6015.24.5
by John Arbash Meinel
Bug #388269. |
2798 |
# get_cached_parent_map should *not* trigger an RPC
|
2799 |
self.assertEqual({}, repo.get_cached_parent_map([r1])) |
|
2800 |
self.assertEqual([], client._calls) |
|
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2801 |
self.assertEqual({r2: (r1,)}, repo.get_parent_map([r2])) |
2802 |
self.assertEqual({r1: (NULL_REVISION,)}, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2803 |
repo.get_cached_parent_map([r1])) |
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2804 |
self.assertEqual( |
2805 |
[('call_with_body_bytes_expecting_body', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2806 |
b'Repository.get_parent_map', (b'quack/', |
2807 |
b'include-missing:', r2), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2808 |
b'\n\n0')], |
|
6015.24.4
by John Arbash Meinel
For it to all work properly, we have to expose get_parent_map_cached on RemoteRepository. |
2809 |
client._calls) |
2810 |
repo.unlock() |
|
2811 |
||
|
3172.5.4
by Robert Collins
Implement get_parent_map for RemoteRepository with caching, based on get_revision_graph. |
2812 |
|
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2813 |
class TestGetParentMapAllowsNew(tests.TestCaseWithTransport): |
2814 |
||
2815 |
def test_allows_new_revisions(self): |
|
2816 |
"""get_parent_map's results can be updated by commit.""" |
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
2817 |
smart_server = test_server.SmartTCPServer_for_testing() |
|
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
2818 |
self.start_server(smart_server) |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2819 |
self.make_branch('branch') |
2820 |
branch = Branch.open(smart_server.get_url() + '/branch') |
|
2821 |
tree = branch.create_checkout('tree', lightweight=True) |
|
2822 |
tree.lock_write() |
|
2823 |
self.addCleanup(tree.unlock) |
|
2824 |
graph = tree.branch.repository.get_graph() |
|
2825 |
# This provides an opportunity for the missing rev-id to be cached.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2826 |
self.assertEqual({}, graph.get_parent_map([b'rev1'])) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
2827 |
tree.commit('message', rev_id=b'rev1') |
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2828 |
graph = tree.branch.repository.get_graph() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2829 |
self.assertEqual({b'rev1': (b'null:',)}, |
2830 |
graph.get_parent_map([b'rev1'])) |
|
|
3835.1.15
by Aaron Bentley
Allow miss caching to be disabled. |
2831 |
|
2832 |
||
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2833 |
class TestRepositoryGetRevisions(TestRemoteRepository): |
2834 |
||
2835 |
def test_hpss_missing_revision(self): |
|
2836 |
transport_path = 'quack' |
|
2837 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2838 |
client.add_success_response_with_body( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2839 |
b'', b'ok', b'10') |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2840 |
self.assertRaises(errors.NoSuchRevision, repo.get_revisions, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2841 |
[b'somerev1', b'anotherrev2']) |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2842 |
self.assertEqual( |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2843 |
[('call_with_body_bytes_expecting_body', |
2844 |
b'Repository.iter_revisions', (b'quack/', ), |
|
2845 |
b"somerev1\nanotherrev2")], |
|
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2846 |
client._calls) |
2847 |
||
2848 |
def test_hpss_get_single_revision(self): |
|
2849 |
transport_path = 'quack' |
|
2850 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2851 |
somerev1 = Revision(b"somerev1") |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2852 |
somerev1.committer = "Joe Committer <joe@example.com>" |
2853 |
somerev1.timestamp = 1321828927 |
|
2854 |
somerev1.timezone = -60 |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2855 |
somerev1.inventory_sha1 = b"691b39be74c67b1212a75fcb19c433aaed903c2b" |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2856 |
somerev1.message = "Message" |
|
7290.46.2
by Jelmer Vernooij
Drop Serializer.write_revision. |
2857 |
body = zlib.compress(b''.join(chk_bencode_serializer.write_revision_to_lines( |
2858 |
somerev1))) |
|
|
6280.9.8
by Jelmer Vernooij
Try to make two calls to zlib.decompressobj.decompress. |
2859 |
# Split up body into two bits to make sure the zlib compression object
|
2860 |
# gets data fed twice.
|
|
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2861 |
client.add_success_response_with_body( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2862 |
[body[:10], body[10:]], b'ok', b'10') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2863 |
revs = repo.get_revisions([b'somerev1']) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
2864 |
self.assertEqual(revs, [somerev1]) |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2865 |
self.assertEqual( |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
2866 |
[('call_with_body_bytes_expecting_body', |
2867 |
b'Repository.iter_revisions', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2868 |
(b'quack/', ), b"somerev1")], |
|
6280.9.1
by Jelmer Vernooij
Add remote side of Repository.iter_revisions. |
2869 |
client._calls) |
2870 |
||
2871 |
||
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2872 |
class TestRepositoryGetRevisionGraph(TestRemoteRepository): |
2873 |
||
2874 |
def test_null_revision(self): |
|
2875 |
# a null revision has the predictable result {}, we should have no wire
|
|
2876 |
# traffic when calling it with this argument
|
|
2877 |
transport_path = 'empty' |
|
2878 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2879 |
client.add_success_response(b'notused') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2880 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
2881 |
# equivalent private method for testing
|
|
2882 |
result = repo._get_revision_graph(NULL_REVISION) |
|
2883 |
self.assertEqual([], client._calls) |
|
2884 |
self.assertEqual({}, result) |
|
2885 |
||
2886 |
def test_none_revision(self): |
|
2887 |
# with none we want the entire graph
|
|
2888 |
r1 = u'\u0e33'.encode('utf8') |
|
2889 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2890 |
lines = [b' '.join([r2, r1]), r1] |
2891 |
encoded_body = b'\n'.join(lines) |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2892 |
|
2893 |
transport_path = 'sinhala' |
|
2894 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2895 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2896 |
# actual RemoteRepository.get_revision_graph is gone, but there's an
|
2897 |
# equivalent private method for testing
|
|
2898 |
result = repo._get_revision_graph(None) |
|
2899 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2900 |
[('call_expecting_body', b'Repository.get_revision_graph', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2901 |
(b'sinhala/', b''))], |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2902 |
client._calls) |
2903 |
self.assertEqual({r1: (), r2: (r1, )}, result) |
|
2904 |
||
2905 |
def test_specific_revision(self): |
|
2906 |
# with a specific revision we want the graph for that
|
|
2907 |
# with none we want the entire graph
|
|
2908 |
r11 = u'\u0e33'.encode('utf8') |
|
2909 |
r12 = u'\xc9'.encode('utf8') |
|
2910 |
r2 = u'\u0dab'.encode('utf8') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2911 |
lines = [b' '.join([r2, r11, r12]), r11, r12] |
2912 |
encoded_body = b'\n'.join(lines) |
|
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2913 |
|
2914 |
transport_path = 'sinhala' |
|
2915 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2916 |
client.add_success_response_with_body(encoded_body, b'ok') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2917 |
result = repo._get_revision_graph(r2) |
2918 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2919 |
[('call_expecting_body', b'Repository.get_revision_graph', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2920 |
(b'sinhala/', r2))], |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2921 |
client._calls) |
2922 |
self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result) |
|
2923 |
||
2924 |
def test_no_such_revision(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2925 |
revid = b'123' |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2926 |
transport_path = 'sinhala' |
2927 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2928 |
client.add_error_response(b'nosuchrevision', revid) |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2929 |
# also check that the right revision is reported in the error
|
2930 |
self.assertRaises(errors.NoSuchRevision, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2931 |
repo._get_revision_graph, revid) |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2932 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2933 |
[('call_expecting_body', b'Repository.get_revision_graph', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2934 |
(b'sinhala/', revid))], |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2935 |
client._calls) |
2936 |
||
2937 |
def test_unexpected_error(self): |
|
2938 |
revid = '123' |
|
2939 |
transport_path = 'sinhala' |
|
2940 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2941 |
client.add_error_response(b'AnUnexpectedError') |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2942 |
e = self.assertRaises(errors.UnknownErrorFromSmartServer, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2943 |
repo._get_revision_graph, revid) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2944 |
self.assertEqual((b'AnUnexpectedError',), e.error_tuple) |
|
3948.3.9
by Martin Pool
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients |
2945 |
|
2946 |
||
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2947 |
class TestRepositoryGetRevIdForRevno(TestRemoteRepository): |
2948 |
||
2949 |
def test_ok(self): |
|
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2950 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2951 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2952 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
2953 |
5, (42, b'rev-foo')), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2954 |
b'success', (b'ok', b'rev-five')) |
2955 |
result = repo.get_rev_id_for_revno(5, (42, b'rev-foo')) |
|
2956 |
self.assertEqual((True, b'rev-five'), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2957 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2958 |
|
2959 |
def test_history_incomplete(self): |
|
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2960 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2961 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2962 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
2963 |
5, (42, b'rev-foo')), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2964 |
b'success', (b'history-incomplete', 10, b'rev-ten')) |
2965 |
result = repo.get_rev_id_for_revno(5, (42, b'rev-foo')) |
|
2966 |
self.assertEqual((False, (10, b'rev-ten')), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2967 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2968 |
|
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2969 |
def test_history_incomplete_with_fallback(self): |
2970 |
"""A 'history-incomplete' response causes the fallback repository to be |
|
2971 |
queried too, if one is set.
|
|
2972 |
"""
|
|
2973 |
# Make a repo with a fallback repo, both using a FakeClient.
|
|
2974 |
format = remote.response_tuple_to_repo_format( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2975 |
(b'yes', b'no', b'yes', self.get_repo_format().network_name())) |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2976 |
repo, client = self.setup_fake_client_and_repository('quack') |
2977 |
repo._format = format |
|
2978 |
fallback_repo, ignored = self.setup_fake_client_and_repository( |
|
2979 |
'fallback') |
|
2980 |
fallback_repo._client = client |
|
|
5158.4.3
by Andrew Bennetts
Fix test_remote tests that accidentally assumed it was ok to stack mismatched formats. |
2981 |
fallback_repo._format = format |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2982 |
repo.add_fallback_repository(fallback_repo) |
2983 |
# First the client should ask the primary repo
|
|
2984 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2985 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
2986 |
1, (42, b'rev-foo')), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2987 |
b'success', (b'history-incomplete', 2, b'rev-two')) |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2988 |
# Then it should ask the fallback, using revno/revid from the
|
2989 |
# history-incomplete response as the known revno/revid.
|
|
2990 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
2991 |
b'Repository.get_rev_id_for_revno', ( |
2992 |
b'fallback/', 1, (2, b'rev-two')), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
2993 |
b'success', (b'ok', b'rev-one')) |
2994 |
result = repo.get_rev_id_for_revno(1, (42, b'rev-foo')) |
|
2995 |
self.assertEqual((True, b'rev-one'), result) |
|
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
2996 |
self.assertFinished(client) |
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
2997 |
|
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
2998 |
def test_nosuchrevision(self): |
2999 |
# 'nosuchrevision' is returned when the known-revid is not found in the
|
|
3000 |
# remote repo. The client translates that response to NoSuchRevision.
|
|
|
4419.2.8
by Andrew Bennetts
Add unit test for RemoteRepository.get_rev_id_for_revno using fallbacks if it gets a history-incomplete response. |
3001 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
3002 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3003 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
3004 |
5, (42, b'rev-foo')), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3005 |
b'error', (b'nosuchrevision', b'rev-foo')) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
3006 |
self.assertRaises( |
3007 |
errors.NoSuchRevision, |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3008 |
repo.get_rev_id_for_revno, 5, (42, b'rev-foo')) |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
3009 |
self.assertFinished(client) |
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
3010 |
|
|
7290.19.4
by Jelmer Vernooij
More tests. |
3011 |
def test_outofbounds(self): |
3012 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
3013 |
client.add_expected_call( |
|
3014 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
|
3015 |
43, (42, b'rev-foo')), |
|
3016 |
b'error', (b'revno-outofbounds', 43, 0, 42)) |
|
3017 |
self.assertRaises( |
|
3018 |
errors.RevnoOutOfBounds, |
|
3019 |
repo.get_rev_id_for_revno, 43, (42, b'rev-foo')) |
|
3020 |
self.assertFinished(client) |
|
3021 |
||
3022 |
def test_outofbounds_old(self): |
|
3023 |
# Older versions of bzr didn't support RevnoOutOfBounds
|
|
3024 |
repo, client = self.setup_fake_client_and_repository('quack') |
|
3025 |
client.add_expected_call( |
|
3026 |
b'Repository.get_rev_id_for_revno', (b'quack/', |
|
3027 |
43, (42, b'rev-foo')), |
|
|
7290.19.6
by Jelmer Vernooij
Fix formatting. |
3028 |
b'error', ( |
3029 |
b'error', b'ValueError', |
|
|
7290.19.4
by Jelmer Vernooij
More tests. |
3030 |
b'requested revno (43) is later than given known revno (42)')) |
3031 |
self.assertRaises( |
|
3032 |
errors.RevnoOutOfBounds, |
|
3033 |
repo.get_rev_id_for_revno, 43, (42, b'rev-foo')) |
|
3034 |
self.assertFinished(client) |
|
3035 |
||
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
3036 |
def test_branch_fallback_locking(self): |
3037 |
"""RemoteBranch.get_rev_id takes a read lock, and tries to call the |
|
3038 |
get_rev_id_for_revno verb. If the verb is unknown the VFS fallback
|
|
3039 |
will be invoked, which will fail if the repo is unlocked.
|
|
3040 |
"""
|
|
3041 |
self.setup_smart_server_with_call_log() |
|
3042 |
tree = self.make_branch_and_memory_tree('.') |
|
3043 |
tree.lock_write() |
|
|
5222.1.1
by Aaron Bentley
Refuse to commit trees with no root. |
3044 |
tree.add('') |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
3045 |
rev1 = tree.commit('First') |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
3046 |
tree.commit('Second') |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
3047 |
tree.unlock() |
3048 |
branch = tree.branch |
|
3049 |
self.assertFalse(branch.is_locked()) |
|
3050 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3051 |
verb = b'Repository.get_rev_id_for_revno' |
|
4634.69.1
by Andrew Bennetts
Apply @needs_read_lock to RemoteBranch.get_rev_id. |
3052 |
self.disable_verb(verb) |
3053 |
self.assertEqual(rev1, branch.get_rev_id(1)) |
|
3054 |
self.assertLength(1, [call for call in self.hpss_calls if |
|
3055 |
call.call.method == verb]) |
|
3056 |
||
|
4419.2.7
by Andrew Bennetts
Add unit tests for RemoteRepository.get_rev_id_for_revno. |
3057 |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
3058 |
class TestRepositoryHasSignatureForRevisionId(TestRemoteRepository): |
3059 |
||
3060 |
def test_has_signature_for_revision_id(self): |
|
3061 |
# ('yes', ) for Repository.has_signature_for_revision_id -> 'True'.
|
|
3062 |
transport_path = 'quack' |
|
3063 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3064 |
client.add_success_response(b'yes') |
3065 |
result = repo.has_signature_for_revision_id(b'A') |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
3066 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3067 |
[('call', b'Repository.has_signature_for_revision_id', |
3068 |
(b'quack/', b'A'))], |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
3069 |
client._calls) |
3070 |
self.assertEqual(True, result) |
|
3071 |
||
3072 |
def test_is_not_shared(self): |
|
3073 |
# ('no', ) for Repository.has_signature_for_revision_id -> 'False'.
|
|
3074 |
transport_path = 'qwack' |
|
3075 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3076 |
client.add_success_response(b'no') |
3077 |
result = repo.has_signature_for_revision_id(b'A') |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
3078 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3079 |
[('call', b'Repository.has_signature_for_revision_id', |
3080 |
(b'qwack/', b'A'))], |
|
|
6265.1.1
by Jelmer Vernooij
Add new HPSS call ``Repository.has_signature_for_revision_id``. |
3081 |
client._calls) |
3082 |
self.assertEqual(False, result) |
|
3083 |
||
3084 |
||
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
3085 |
class TestRepositoryPhysicalLockStatus(TestRemoteRepository): |
3086 |
||
3087 |
def test_get_physical_lock_status_yes(self): |
|
3088 |
transport_path = 'qwack' |
|
3089 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3090 |
client.add_success_response(b'yes') |
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
3091 |
result = repo.get_physical_lock_status() |
3092 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3093 |
[('call', b'Repository.get_physical_lock_status', |
3094 |
(b'qwack/', ))], |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
3095 |
client._calls) |
3096 |
self.assertEqual(True, result) |
|
3097 |
||
3098 |
def test_get_physical_lock_status_no(self): |
|
3099 |
transport_path = 'qwack' |
|
3100 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3101 |
client.add_success_response(b'no') |
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
3102 |
result = repo.get_physical_lock_status() |
3103 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3104 |
[('call', b'Repository.get_physical_lock_status', |
3105 |
(b'qwack/', ))], |
|
|
6280.6.1
by Jelmer Vernooij
Implement remote side of {Branch,Repository}.get_physical_lock_status. |
3106 |
client._calls) |
3107 |
self.assertEqual(False, result) |
|
3108 |
||
3109 |
||
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
3110 |
class TestRepositoryIsShared(TestRemoteRepository): |
3111 |
||
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3112 |
def test_is_shared(self): |
3113 |
# ('yes', ) for Repository.is_shared -> 'True'.
|
|
3114 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3115 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3116 |
client.add_success_response(b'yes') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3117 |
result = repo.is_shared() |
3118 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3119 |
[('call', b'Repository.is_shared', (b'quack/',))], |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3120 |
client._calls) |
3121 |
self.assertEqual(True, result) |
|
3122 |
||
3123 |
def test_is_not_shared(self): |
|
3124 |
# ('no', ) for Repository.is_shared -> 'False'.
|
|
3125 |
transport_path = 'qwack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3126 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3127 |
client.add_success_response(b'no') |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3128 |
result = repo.is_shared() |
3129 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3130 |
[('call', b'Repository.is_shared', (b'qwack/',))], |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
3131 |
client._calls) |
3132 |
self.assertEqual(False, result) |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3133 |
|
3134 |
||
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3135 |
class TestRepositoryMakeWorkingTrees(TestRemoteRepository): |
3136 |
||
3137 |
def test_make_working_trees(self): |
|
3138 |
# ('yes', ) for Repository.make_working_trees -> 'True'.
|
|
3139 |
transport_path = 'quack' |
|
3140 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3141 |
client.add_success_response(b'yes') |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3142 |
result = repo.make_working_trees() |
3143 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3144 |
[('call', b'Repository.make_working_trees', (b'quack/',))], |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3145 |
client._calls) |
3146 |
self.assertEqual(True, result) |
|
3147 |
||
3148 |
def test_no_working_trees(self): |
|
3149 |
# ('no', ) for Repository.make_working_trees -> 'False'.
|
|
3150 |
transport_path = 'qwack' |
|
3151 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3152 |
client.add_success_response(b'no') |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3153 |
result = repo.make_working_trees() |
3154 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3155 |
[('call', b'Repository.make_working_trees', (b'qwack/',))], |
|
6263.2.1
by Jelmer Vernooij
Add hpss call ``Repository.make_working_trees`` |
3156 |
client._calls) |
3157 |
self.assertEqual(False, result) |
|
3158 |
||
3159 |
||
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3160 |
class TestRepositoryLockWrite(TestRemoteRepository): |
3161 |
||
3162 |
def test_lock_write(self): |
|
3163 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3164 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3165 |
client.add_success_response(b'ok', b'a token') |
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
3166 |
token = repo.lock_write().repository_token |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3167 |
self.assertEqual( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3168 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3169 |
client._calls) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3170 |
self.assertEqual(b'a token', token) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3171 |
|
3172 |
def test_lock_write_already_locked(self): |
|
3173 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3174 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3175 |
client.add_error_response(b'LockContention') |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3176 |
self.assertRaises(errors.LockContention, repo.lock_write) |
3177 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3178 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
3179 |
client._calls) |
3180 |
||
3181 |
def test_lock_write_unlockable(self): |
|
3182 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3183 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3184 |
client.add_error_response(b'UnlockableTransport') |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
3185 |
self.assertRaises(errors.UnlockableTransport, repo.lock_write) |
3186 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3187 |
[('call', b'Repository.lock_write', (b'quack/', b''))], |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3188 |
client._calls) |
3189 |
||
3190 |
||
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3191 |
class TestRepositoryWriteGroups(TestRemoteRepository): |
3192 |
||
3193 |
def test_start_write_group(self): |
|
3194 |
transport_path = 'quack' |
|
3195 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3196 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3197 |
b'Repository.lock_write', (b'quack/', b''), |
3198 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3199 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3200 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
3201 |
b'success', (b'ok', (b'token1', ))) |
|
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3202 |
repo.lock_write() |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3203 |
repo.start_write_group() |
3204 |
||
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3205 |
def test_start_write_group_unsuspendable(self): |
3206 |
# Some repositories do not support suspending write
|
|
3207 |
# groups. For those, fall back to the "real" repository.
|
|
3208 |
transport_path = 'quack' |
|
3209 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3210 |
|
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3211 |
def stub_ensure_real(): |
3212 |
client._calls.append(('_ensure_real',)) |
|
3213 |
repo._real_repository = _StubRealPackRepository(client._calls) |
|
3214 |
repo._ensure_real = stub_ensure_real |
|
3215 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3216 |
b'Repository.lock_write', (b'quack/', b''), |
3217 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3218 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3219 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
3220 |
b'error', (b'UnsuspendableWriteGroup',)) |
|
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3221 |
repo.lock_write() |
3222 |
repo.start_write_group() |
|
|
6963.1.2
by Jelmer Vernooij
Fix some more tests. |
3223 |
self.assertEqual(client._calls[-2:], [ |
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3224 |
('_ensure_real',), |
3225 |
('start_write_group',)]) |
|
3226 |
||
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3227 |
def test_commit_write_group(self): |
3228 |
transport_path = 'quack' |
|
3229 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3230 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3231 |
b'Repository.lock_write', (b'quack/', b''), |
3232 |
b'success', (b'ok', b'a token')) |
|
3233 |
client.add_expected_call( |
|
3234 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
3235 |
b'success', (b'ok', [b'token1'])) |
|
3236 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3237 |
b'Repository.commit_write_group', (b'quack/', |
3238 |
b'a token', [b'token1']), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3239 |
b'success', (b'ok',)) |
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3240 |
repo.lock_write() |
3241 |
repo.start_write_group() |
|
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3242 |
repo.commit_write_group() |
3243 |
||
3244 |
def test_abort_write_group(self): |
|
3245 |
transport_path = 'quack' |
|
3246 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3247 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3248 |
b'Repository.lock_write', (b'quack/', b''), |
3249 |
b'success', (b'ok', b'a token')) |
|
3250 |
client.add_expected_call( |
|
3251 |
b'Repository.start_write_group', (b'quack/', b'a token'), |
|
3252 |
b'success', (b'ok', [b'token1'])) |
|
3253 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3254 |
b'Repository.abort_write_group', (b'quack/', |
3255 |
b'a token', [b'token1']), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3256 |
b'success', (b'ok',)) |
|
6280.7.2
by Jelmer Vernooij
Add HPSS calls ``Repository.start_write_group``, ``Repository.abort_write_group`` and ``Repository.commit_write_group``. |
3257 |
repo.lock_write() |
3258 |
repo.start_write_group() |
|
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3259 |
repo.abort_write_group(False) |
3260 |
||
3261 |
def test_suspend_write_group(self): |
|
3262 |
transport_path = 'quack' |
|
3263 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
3264 |
self.assertEqual([], repo.suspend_write_group()) |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3265 |
|
3266 |
def test_resume_write_group(self): |
|
3267 |
transport_path = 'quack' |
|
3268 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3269 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3270 |
b'Repository.lock_write', (b'quack/', b''), |
3271 |
b'success', (b'ok', b'a token')) |
|
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3272 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3273 |
b'Repository.check_write_group', (b'quack/', |
3274 |
b'a token', [b'token1']), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3275 |
b'success', (b'ok',)) |
|
6280.7.6
by Jelmer Vernooij
Fix remaining tests. |
3276 |
repo.lock_write() |
|
7045.2.20
by Jelmer Vernooij
Fix remaining tests. |
3277 |
repo.resume_write_group(['token1']) |
|
6280.7.1
by Jelmer Vernooij
Implement RemoteRepository side of write group HPSS methods. |
3278 |
|
3279 |
||
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3280 |
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository): |
3281 |
||
3282 |
def test_backwards_compat(self): |
|
3283 |
self.setup_smart_server_with_call_log() |
|
3284 |
repo = self.make_repository('.') |
|
3285 |
self.reset_smart_call_log() |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3286 |
verb = b'Repository.set_make_working_trees' |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3287 |
self.disable_verb(verb) |
3288 |
repo.set_make_working_trees(True) |
|
3289 |
call_count = len([call for call in self.hpss_calls if |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3290 |
call.call.method == verb]) |
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3291 |
self.assertEqual(1, call_count) |
3292 |
||
3293 |
def test_current(self): |
|
3294 |
transport_path = 'quack' |
|
3295 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3296 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3297 |
b'Repository.set_make_working_trees', (b'quack/', b'True'), |
3298 |
b'success', (b'ok',)) |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3299 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3300 |
b'Repository.set_make_working_trees', (b'quack/', b'False'), |
3301 |
b'success', (b'ok',)) |
|
|
4017.3.4
by Robert Collins
Create a verb for Repository.set_make_working_trees. |
3302 |
repo.set_make_working_trees(True) |
3303 |
repo.set_make_working_trees(False) |
|
3304 |
||
3305 |
||
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3306 |
class TestRepositoryUnlock(TestRemoteRepository): |
3307 |
||
3308 |
def test_unlock(self): |
|
3309 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3310 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3311 |
client.add_success_response(b'ok', b'a token') |
3312 |
client.add_success_response(b'ok') |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3313 |
repo.lock_write() |
3314 |
repo.unlock() |
|
3315 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3316 |
[('call', b'Repository.lock_write', (b'quack/', b'')), |
3317 |
('call', b'Repository.unlock', (b'quack/', b'a token'))], |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3318 |
client._calls) |
3319 |
||
3320 |
def test_unlock_wrong_token(self): |
|
3321 |
# If somehow the token is wrong, unlock will raise TokenMismatch.
|
|
3322 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3323 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3324 |
client.add_success_response(b'ok', b'a token') |
3325 |
client.add_error_response(b'TokenMismatch') |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
3326 |
repo.lock_write() |
3327 |
self.assertRaises(errors.TokenMismatch, repo.unlock) |
|
3328 |
||
3329 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
3330 |
class TestRepositoryHasRevision(TestRemoteRepository): |
3331 |
||
3332 |
def test_none(self): |
|
3333 |
# repo.has_revision(None) should not cause any traffic.
|
|
3334 |
transport_path = 'quack' |
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3335 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
3336 |
|
3337 |
# The null revision is always there, so has_revision(None) == True.
|
|
|
3172.3.3
by Robert Collins
Missed one occurence of None -> NULL_REVISION. |
3338 |
self.assertEqual(True, repo.has_revision(NULL_REVISION)) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
3339 |
|
3340 |
# The remote repo shouldn't be accessed.
|
|
3341 |
self.assertEqual([], client._calls) |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3342 |
|
3343 |
||
|
6280.10.7
by Jelmer Vernooij
Fix remote. |
3344 |
class TestRepositoryIterFilesBytes(TestRemoteRepository): |
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3345 |
"""Test Repository.iter_file_bytes.""" |
3346 |
||
3347 |
def test_single(self): |
|
3348 |
transport_path = 'quack' |
|
3349 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3350 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3351 |
b'Repository.iter_files_bytes', (b'quack/', ), |
3352 |
b'success', (b'ok',), iter([b"ok\x000", b"\n", zlib.compress(b"mydata" * 10)])) |
|
3353 |
for (identifier, byte_stream) in repo.iter_files_bytes([(b"somefile", |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3354 |
b"somerev", b"myid")]): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3355 |
self.assertEqual(b"myid", identifier) |
3356 |
self.assertEqual(b"".join(byte_stream), b"mydata" * 10) |
|
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3357 |
|
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3358 |
def test_missing(self): |
3359 |
transport_path = 'quack' |
|
3360 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3361 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3362 |
b'Repository.iter_files_bytes', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3363 |
(b'quack/', ), |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3364 |
b'error', (b'RevisionNotPresent', b'somefile', b'somerev'), |
3365 |
iter([b"absent\0somefile\0somerev\n"])) |
|
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3366 |
self.assertRaises(errors.RevisionNotPresent, list, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3367 |
repo.iter_files_bytes( |
3368 |
[(b"somefile", b"somerev", b"myid")])) |
|
|
6280.10.3
by Jelmer Vernooij
Fix iter_file_bytes. |
3369 |
|
|
6280.10.1
by Jelmer Vernooij
Add remote side of Repository.iter_file_bytes. |
3370 |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3371 |
class TestRepositoryInsertStreamBase(TestRemoteRepository): |
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
3372 |
"""Base class for Repository.insert_stream and .insert_stream_1.19 |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3373 |
tests.
|
3374 |
"""
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3375 |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3376 |
def checkInsertEmptyStream(self, repo, client): |
3377 |
"""Insert an empty stream, checking the result. |
|
3378 |
||
3379 |
This checks that there are no resume_tokens or missing_keys, and that
|
|
3380 |
the client is finished.
|
|
3381 |
"""
|
|
3382 |
sink = repo._get_sink() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
3383 |
fmt = repository.format_registry.get_default() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3384 |
resume_tokens, missing_keys = sink.insert_stream([], fmt, []) |
3385 |
self.assertEqual([], resume_tokens) |
|
3386 |
self.assertEqual(set(), missing_keys) |
|
3387 |
self.assertFinished(client) |
|
3388 |
||
3389 |
||
3390 |
class TestRepositoryInsertStream(TestRepositoryInsertStreamBase): |
|
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
3391 |
"""Tests for using Repository.insert_stream verb when the _1.19 variant is |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3392 |
not available.
|
3393 |
||
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
3394 |
This test case is very similar to TestRepositoryInsertStream_1_19.
|
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3395 |
"""
|
3396 |
||
3397 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
3398 |
super(TestRepositoryInsertStream, self).setUp() |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3399 |
self.disable_verb(b'Repository.insert_stream_1.19') |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3400 |
|
3401 |
def test_unlocked_repo(self): |
|
3402 |
transport_path = 'quack' |
|
3403 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3404 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3405 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3406 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3407 |
client.add_expected_call( |
|
3408 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3409 |
b'success', (b'ok',)) |
|
3410 |
client.add_expected_call( |
|
3411 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3412 |
b'success', (b'ok',)) |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3413 |
self.checkInsertEmptyStream(repo, client) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3414 |
|
3415 |
def test_locked_repo_with_no_lock_token(self): |
|
3416 |
transport_path = 'quack' |
|
3417 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3418 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3419 |
b'Repository.lock_write', (b'quack/', b''), |
3420 |
b'success', (b'ok', b'')) |
|
3421 |
client.add_expected_call( |
|
3422 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3423 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3424 |
client.add_expected_call( |
|
3425 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3426 |
b'success', (b'ok',)) |
|
3427 |
client.add_expected_call( |
|
3428 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3429 |
b'success', (b'ok',)) |
|
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3430 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3431 |
self.checkInsertEmptyStream(repo, client) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3432 |
|
3433 |
def test_locked_repo_with_lock_token(self): |
|
3434 |
transport_path = 'quack' |
|
3435 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3436 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3437 |
b'Repository.lock_write', (b'quack/', b''), |
3438 |
b'success', (b'ok', b'a token')) |
|
3439 |
client.add_expected_call( |
|
3440 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3441 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3442 |
client.add_expected_call( |
|
3443 |
b'Repository.insert_stream_locked', (b'quack/', b'', b'a token'), |
|
3444 |
b'success', (b'ok',)) |
|
3445 |
client.add_expected_call( |
|
3446 |
b'Repository.insert_stream_locked', (b'quack/', b'', b'a token'), |
|
3447 |
b'success', (b'ok',)) |
|
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3448 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3449 |
self.checkInsertEmptyStream(repo, client) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3450 |
|
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3451 |
def test_stream_with_inventory_deltas(self): |
|
4476.3.71
by Andrew Bennetts
Clearer comments prompted by Robert's review. |
3452 |
"""'inventory-deltas' substreams cannot be sent to the |
3453 |
Repository.insert_stream verb, because not all servers that implement
|
|
3454 |
that verb will accept them. So when one is encountered the RemoteSink
|
|
3455 |
immediately stops using that verb and falls back to VFS insert_stream.
|
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3456 |
"""
|
3457 |
transport_path = 'quack' |
|
3458 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3459 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3460 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3461 |
b'unknown', (b'Repository.insert_stream_1.19',)) |
|
3462 |
client.add_expected_call( |
|
3463 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3464 |
b'success', (b'ok',)) |
|
3465 |
client.add_expected_call( |
|
3466 |
b'Repository.insert_stream', (b'quack/', b''), |
|
3467 |
b'success', (b'ok',)) |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3468 |
# Create a fake real repository for insert_stream to fall back on, so
|
3469 |
# that we can directly see the records the RemoteSink passes to the
|
|
3470 |
# real sink.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3471 |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3472 |
class FakeRealSink: |
3473 |
def __init__(self): |
|
3474 |
self.records = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3475 |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3476 |
def insert_stream(self, stream, src_format, resume_tokens): |
3477 |
for substream_kind, substream in stream: |
|
3478 |
self.records.append( |
|
3479 |
(substream_kind, [record.key for record in substream])) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3480 |
return [b'fake tokens'], [b'fake missing keys'] |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3481 |
fake_real_sink = FakeRealSink() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3482 |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3483 |
class FakeRealRepository: |
3484 |
def _get_sink(self): |
|
3485 |
return fake_real_sink |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3486 |
|
|
4634.35.20
by Andrew Bennetts
Fix test_remote. |
3487 |
def is_in_write_group(self): |
3488 |
return False |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3489 |
|
|
4634.35.20
by Andrew Bennetts
Fix test_remote. |
3490 |
def refresh_data(self): |
3491 |
return True |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3492 |
repo._real_repository = FakeRealRepository() |
3493 |
sink = repo._get_sink() |
|
|
5651.3.9
by Jelmer Vernooij
Avoid using deprecated functions. |
3494 |
fmt = repository.format_registry.get_default() |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3495 |
stream = self.make_stream_with_inv_deltas(fmt) |
3496 |
resume_tokens, missing_keys = sink.insert_stream(stream, fmt, []) |
|
3497 |
# Every record from the first inventory delta should have been sent to
|
|
3498 |
# the VFS sink.
|
|
3499 |
expected_records = [ |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3500 |
('inventory-deltas', [(b'rev2',), (b'rev3',)]), |
3501 |
('texts', [(b'some-rev', b'some-file')])] |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3502 |
self.assertEqual(expected_records, fake_real_sink.records) |
3503 |
# The return values from the real sink's insert_stream are propagated
|
|
3504 |
# back to the original caller.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3505 |
self.assertEqual([b'fake tokens'], resume_tokens) |
3506 |
self.assertEqual([b'fake missing keys'], missing_keys) |
|
|
4476.3.40
by Andrew Bennetts
Merge bzr.dev. |
3507 |
self.assertFinished(client) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3508 |
|
3509 |
def make_stream_with_inv_deltas(self, fmt): |
|
3510 |
"""Make a simple stream with an inventory delta followed by more |
|
3511 |
records and more substreams to test that all records and substreams
|
|
3512 |
from that point on are used.
|
|
3513 |
||
3514 |
This sends, in order:
|
|
3515 |
* inventories substream: rev1, rev2, rev3. rev2 and rev3 are
|
|
3516 |
inventory-deltas.
|
|
3517 |
* texts substream: (some-rev, some-file)
|
|
3518 |
"""
|
|
3519 |
# Define a stream using generators so that it isn't rewindable.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3520 |
inv = inventory.Inventory(revision_id=b'rev1') |
3521 |
inv.root.revision = b'rev1' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3522 |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3523 |
def stream_with_inv_delta(): |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3524 |
yield ('inventories', inventories_substream()) |
3525 |
yield ('inventory-deltas', inventory_delta_substream()) |
|
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3526 |
yield ('texts', [ |
3527 |
versionedfile.FulltextContentFactory( |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
3528 |
(b'some-rev', b'some-file'), (), None, b'content')]) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3529 |
|
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3530 |
def inventories_substream(): |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3531 |
# An empty inventory fulltext. This will be streamed normally.
|
|
7467.2.1
by Jelmer Vernooij
Replace write_inventory_to_string with write_inventory_to_chunks. |
3532 |
chunks = fmt._serializer.write_inventory_to_lines(inv) |
3533 |
yield versionedfile.ChunkedContentFactory( |
|
3534 |
(b'rev1',), (), None, chunks, chunks_are_lines=True) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3535 |
|
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3536 |
def inventory_delta_substream(): |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3537 |
# An inventory delta. This can't be streamed via this verb, so it
|
3538 |
# will trigger a fallback to VFS insert_stream.
|
|
3539 |
entry = inv.make_entry( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3540 |
'directory', 'newdir', inv.root.file_id, b'newdir-id') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
3541 |
entry.revision = b'ghost' |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3542 |
delta = [(None, 'newdir', b'newdir-id', entry)] |
|
4476.3.76
by Andrew Bennetts
Split out InventoryDeltaDeserializer from InventoryDeltaSerializer. |
3543 |
serializer = inventory_delta.InventoryDeltaSerializer( |
3544 |
versioned_root=True, tree_references=False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3545 |
lines = serializer.delta_to_lines(b'rev1', b'rev2', delta) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3546 |
yield versionedfile.ChunkedContentFactory( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3547 |
(b'rev2',), ((b'rev1',)), None, lines) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3548 |
# Another delta.
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3549 |
lines = serializer.delta_to_lines(b'rev1', b'rev3', delta) |
|
4476.3.56
by Andrew Bennetts
Update test_stream_with_inventory_deltas for inventory-deltas substream. |
3550 |
yield versionedfile.ChunkedContentFactory( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3551 |
(b'rev3',), ((b'rev1',)), None, lines) |
|
4476.3.36
by Andrew Bennetts
Add a somewhat complex test to exercise the fallback-to-vfs logic in RemoteSink when an inventory-delta is encountered and the 1.18 verb isn't accepted. |
3552 |
return stream_with_inv_delta() |
3553 |
||
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3554 |
|
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
3555 |
class TestRepositoryInsertStream_1_19(TestRepositoryInsertStreamBase): |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3556 |
|
3557 |
def test_unlocked_repo(self): |
|
3558 |
transport_path = 'quack' |
|
3559 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3560 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3561 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3562 |
b'success', (b'ok',)) |
|
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3563 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3564 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
3565 |
b'success', (b'ok',)) |
|
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3566 |
self.checkInsertEmptyStream(repo, client) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3567 |
|
3568 |
def test_locked_repo_with_no_lock_token(self): |
|
3569 |
transport_path = 'quack' |
|
3570 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3571 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3572 |
b'Repository.lock_write', (b'quack/', b''), |
3573 |
b'success', (b'ok', b'')) |
|
3574 |
client.add_expected_call( |
|
3575 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3576 |
b'success', (b'ok',)) |
|
3577 |
client.add_expected_call( |
|
3578 |
b'Repository.insert_stream_1.19', (b'quack/', b''), |
|
3579 |
b'success', (b'ok',)) |
|
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3580 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3581 |
self.checkInsertEmptyStream(repo, client) |
|
4476.3.32
by Andrew Bennetts
Move disable_verb into base TestCase to remove duplication, fix trivial test failures due to new insert_stream verb in test_remote (and also add some trivial tests for the new verb). |
3582 |
|
3583 |
def test_locked_repo_with_lock_token(self): |
|
3584 |
transport_path = 'quack' |
|
3585 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3586 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3587 |
b'Repository.lock_write', (b'quack/', b''), |
3588 |
b'success', (b'ok', b'a token')) |
|
3589 |
client.add_expected_call( |
|
3590 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3591 |
b'success', (b'ok',)) |
|
3592 |
client.add_expected_call( |
|
3593 |
b'Repository.insert_stream_1.19', (b'quack/', b'', b'a token'), |
|
3594 |
b'success', (b'ok',)) |
|
|
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
3595 |
repo.lock_write() |
|
4476.3.79
by Andrew Bennetts
Remove a bit of duplication from Repository.insert_stream* tests. |
3596 |
self.checkInsertEmptyStream(repo, client) |
|
4144.3.2
by Andrew Bennetts
Use Repository.insert_stream_locked if there is a lock_token for the remote repo. |
3597 |
|
3598 |
||
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3599 |
class TestRepositoryTarball(TestRemoteRepository): |
3600 |
||
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3601 |
# This is a canned tarball reponse we can validate against
|
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
3602 |
tarball_content = base64.b64decode( |
|
2018.18.23
by Martin Pool
review cleanups |
3603 |
'QlpoOTFBWSZTWdGkj3wAAWF/k8aQACBIB//A9+8cIX/v33AACEAYABAECEACNz'
|
3604 |
'JqsgJJFPTSnk1A3qh6mTQAAAANPUHkagkSTEkaA09QaNAAAGgAAAcwCYCZGAEY'
|
|
3605 |
'mJhMJghpiaYBUkKammSHqNMZQ0NABkNAeo0AGneAevnlwQoGzEzNVzaYxp/1Uk'
|
|
3606 |
'xXzA1CQX0BJMZZLcPBrluJir5SQyijWHYZ6ZUtVqqlYDdB2QoCwa9GyWwGYDMA'
|
|
3607 |
'OQYhkpLt/OKFnnlT8E0PmO8+ZNSo2WWqeCzGB5fBXZ3IvV7uNJVE7DYnWj6qwB'
|
|
3608 |
'k5DJDIrQ5OQHHIjkS9KqwG3mc3t+F1+iujb89ufyBNIKCgeZBWrl5cXxbMGoMs'
|
|
3609 |
'c9JuUkg5YsiVcaZJurc6KLi6yKOkgCUOlIlOpOoXyrTJjK8ZgbklReDdwGmFgt'
|
|
3610 |
'dkVsAIslSVCd4AtACSLbyhLHryfb14PKegrVDba+U8OL6KQtzdM5HLjAc8/p6n'
|
|
3611 |
'0lgaWU8skgO7xupPTkyuwheSckejFLK5T4ZOo0Gda9viaIhpD1Qn7JqqlKAJqC'
|
|
3612 |
'QplPKp2nqBWAfwBGaOwVrz3y1T+UZZNismXHsb2Jq18T+VaD9k4P8DqE3g70qV'
|
|
3613 |
'JLurpnDI6VS5oqDDPVbtVjMxMxMg4rzQVipn2Bv1fVNK0iq3Gl0hhnnHKm/egy'
|
|
3614 |
'nWQ7QH/F3JFOFCQ0aSPfA='
|
|
|
6791.2.3
by Jelmer Vernooij
Fix more imports. |
3615 |
)
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3616 |
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3617 |
def test_repository_tarball(self): |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3618 |
# Test that Repository.tarball generates the right operations
|
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3619 |
transport_path = 'repo' |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3620 |
expected_calls = [('call_expecting_body', b'Repository.tarball', |
3621 |
(b'repo/', b'bz2',),), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3622 |
]
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3623 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3624 |
client.add_success_response_with_body(self.tarball_content, b'ok') |
|
2018.18.7
by Martin Pool
(broken) Start addng client proxy test for Repository.tarball |
3625 |
# Now actually ask for the tarball
|
|
3245.4.24
by Andrew Bennetts
Consistently raise errors from the server as ErrorFromSmartServer exceptions. |
3626 |
tarball_file = repo._get_tarball('bz2') |
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
3627 |
try: |
3628 |
self.assertEqual(expected_calls, client._calls) |
|
3629 |
self.assertEqual(self.tarball_content, tarball_file.read()) |
|
3630 |
finally: |
|
3631 |
tarball_file.close() |
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
3632 |
|
3633 |
||
3634 |
class TestRemoteRepositoryCopyContent(tests.TestCaseWithTransport): |
|
3635 |
"""RemoteRepository.copy_content_into optimizations""" |
|
3636 |
||
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
3637 |
def test_copy_content_remote_to_local(self): |
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
3638 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
3639 |
src_repo = self.make_repository('repo1') |
3640 |
src_repo = repository.Repository.open(self.get_url('repo1')) |
|
3641 |
# At the moment the tarball-based copy_content_into can't write back
|
|
3642 |
# into a smart server. It would be good if it could upload the
|
|
3643 |
# tarball; once that works we'd have to create repositories of
|
|
3644 |
# different formats. -- mbp 20070410
|
|
3645 |
dest_url = self.get_vfs_only_url('repo2') |
|
3646 |
dest_bzrdir = BzrDir.create(dest_url) |
|
3647 |
dest_repo = dest_bzrdir.create_repository() |
|
3648 |
self.assertFalse(isinstance(dest_repo, RemoteRepository)) |
|
3649 |
self.assertTrue(isinstance(src_repo, RemoteRepository)) |
|
3650 |
src_repo.copy_content_into(dest_repo) |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3651 |
|
3652 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3653 |
class _StubRealPackRepository(object): |
3654 |
||
3655 |
def __init__(self, calls): |
|
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
3656 |
self.calls = calls |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3657 |
self._pack_collection = _StubPackCollection(calls) |
3658 |
||
|
6280.7.8
by Jelmer Vernooij
make sure start_write_group falls back to real_repository if write groups aren't suspendable. |
3659 |
def start_write_group(self): |
3660 |
self.calls.append(('start_write_group',)) |
|
3661 |
||
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
3662 |
def is_in_write_group(self): |
3663 |
return False |
|
3664 |
||
3665 |
def refresh_data(self): |
|
3666 |
self.calls.append(('pack collection reload_pack_names',)) |
|
3667 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3668 |
|
3669 |
class _StubPackCollection(object): |
|
3670 |
||
3671 |
def __init__(self, calls): |
|
3672 |
self.calls = calls |
|
3673 |
||
3674 |
def autopack(self): |
|
3675 |
self.calls.append(('pack collection autopack',)) |
|
3676 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3677 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3678 |
class TestRemotePackRepositoryAutoPack(TestRemoteRepository): |
3679 |
"""Tests for RemoteRepository.autopack implementation.""" |
|
3680 |
||
3681 |
def test_ok(self): |
|
3682 |
"""When the server returns 'ok' and there's no _real_repository, then |
|
3683 |
nothing else happens: the autopack method is done.
|
|
3684 |
"""
|
|
3685 |
transport_path = 'quack' |
|
3686 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3687 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3688 |
b'PackRepository.autopack', (b'quack/',), b'success', (b'ok',)) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3689 |
repo.autopack() |
|
4523.3.1
by Andrew Bennetts
Change FakeClient.finished_test into a more typical assertion method on TestRemote. |
3690 |
self.assertFinished(client) |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3691 |
|
3692 |
def test_ok_with_real_repo(self): |
|
3693 |
"""When the server returns 'ok' and there is a _real_repository, then |
|
3694 |
the _real_repository's reload_pack_name's method will be called.
|
|
3695 |
"""
|
|
3696 |
transport_path = 'quack' |
|
3697 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3698 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3699 |
b'PackRepository.autopack', (b'quack/',), |
3700 |
b'success', (b'ok',)) |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3701 |
repo._real_repository = _StubRealPackRepository(client._calls) |
3702 |
repo.autopack() |
|
3703 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3704 |
[('call', b'PackRepository.autopack', (b'quack/',)), |
|
3801.1.13
by Andrew Bennetts
Revert returning of pack-names from the RPC. |
3705 |
('pack collection reload_pack_names',)], |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3706 |
client._calls) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3707 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3708 |
def test_backwards_compatibility(self): |
3709 |
"""If the server does not recognise the PackRepository.autopack verb, |
|
3710 |
fallback to the real_repository's implementation.
|
|
3711 |
"""
|
|
3712 |
transport_path = 'quack' |
|
3713 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3714 |
client.add_unknown_method_response(b'PackRepository.autopack') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3715 |
|
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3716 |
def stub_ensure_real(): |
3717 |
client._calls.append(('_ensure_real',)) |
|
3718 |
repo._real_repository = _StubRealPackRepository(client._calls) |
|
3719 |
repo._ensure_real = stub_ensure_real |
|
3720 |
repo.autopack() |
|
3721 |
self.assertEqual( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3722 |
[('call', b'PackRepository.autopack', (b'quack/',)), |
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3723 |
('_ensure_real',), |
3724 |
('pack collection autopack',)], |
|
3725 |
client._calls) |
|
3726 |
||
|
5677.2.2
by Martin
Give clearer message when remote server reports a MemoryError |
3727 |
def test_oom_error_reporting(self): |
3728 |
"""An out-of-memory condition on the server is reported clearly""" |
|
3729 |
transport_path = 'quack' |
|
3730 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
3731 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3732 |
b'PackRepository.autopack', (b'quack/',), |
3733 |
b'error', (b'MemoryError',)) |
|
|
5677.2.2
by Martin
Give clearer message when remote server reports a MemoryError |
3734 |
err = self.assertRaises(errors.BzrError, repo.autopack) |
3735 |
self.assertContainsRe(str(err), "^remote server out of mem") |
|
3736 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3737 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3738 |
class TestErrorTranslationBase(tests.TestCaseWithMemoryTransport): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3739 |
"""Base class for unit tests for breezy.bzr.remote._translate_error.""" |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3740 |
|
3741 |
def translateTuple(self, error_tuple, **context): |
|
3742 |
"""Call _translate_error with an ErrorFromSmartServer built from the |
|
3743 |
given error_tuple.
|
|
3744 |
||
3745 |
:param error_tuple: A tuple of a smart server response, as would be
|
|
3746 |
passed to an ErrorFromSmartServer.
|
|
3747 |
:kwargs context: context items to call _translate_error with.
|
|
3748 |
||
3749 |
:returns: The error raised by _translate_error.
|
|
3750 |
"""
|
|
3751 |
# Raise the ErrorFromSmartServer before passing it as an argument,
|
|
3752 |
# because _translate_error may need to re-raise it with a bare 'raise'
|
|
3753 |
# statement.
|
|
3754 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
|
3755 |
translated_error = self.translateErrorFromSmartServer( |
|
3756 |
server_error, **context) |
|
3757 |
return translated_error |
|
3758 |
||
3759 |
def translateErrorFromSmartServer(self, error_object, **context): |
|
3760 |
"""Like translateTuple, but takes an already constructed |
|
3761 |
ErrorFromSmartServer rather than a tuple.
|
|
3762 |
"""
|
|
3763 |
try: |
|
3764 |
raise error_object |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
3765 |
except errors.ErrorFromSmartServer as server_error: |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3766 |
translated_error = self.assertRaises( |
3767 |
errors.BzrError, remote._translate_error, server_error, |
|
3768 |
**context) |
|
3769 |
return translated_error |
|
3770 |
||
|
3801.1.4
by Andrew Bennetts
Add tests for autopack RPC. |
3771 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3772 |
class TestErrorTranslationSuccess(TestErrorTranslationBase): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3773 |
"""Unit tests for breezy.bzr.remote._translate_error. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3774 |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3775 |
Given an ErrorFromSmartServer (which has an error tuple from a smart
|
3776 |
server) and some context, _translate_error raises more specific errors from
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
3777 |
breezy.errors.
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3778 |
|
3779 |
This test case covers the cases where _translate_error succeeds in
|
|
3780 |
translating an ErrorFromSmartServer to something better. See
|
|
3781 |
TestErrorTranslationRobustness for other cases.
|
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3782 |
"""
|
3783 |
||
3784 |
def test_NoSuchRevision(self): |
|
3785 |
branch = self.make_branch('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3786 |
revid = b'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3787 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3788 |
(b'NoSuchRevision', revid), branch=branch) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3789 |
expected_error = errors.NoSuchRevision(branch, revid) |
3790 |
self.assertEqual(expected_error, translated_error) |
|
3791 |
||
3792 |
def test_nosuchrevision(self): |
|
3793 |
repository = self.make_repository('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3794 |
revid = b'revid' |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3795 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3796 |
(b'nosuchrevision', revid), repository=repository) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3797 |
expected_error = errors.NoSuchRevision(repository, revid) |
3798 |
self.assertEqual(expected_error, translated_error) |
|
3799 |
||
3800 |
def test_nobranch(self): |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3801 |
bzrdir = self.make_controldir('') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3802 |
translated_error = self.translateTuple((b'nobranch',), bzrdir=bzrdir) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3803 |
expected_error = errors.NotBranchError(path=bzrdir.root_transport.base) |
3804 |
self.assertEqual(expected_error, translated_error) |
|
3805 |
||
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
3806 |
def test_nobranch_one_arg(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3807 |
bzrdir = self.make_controldir('') |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
3808 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3809 |
(b'nobranch', b'extra detail'), bzrdir=bzrdir) |
|
4734.4.8
by Andrew Bennetts
Fix HPSS tests; pass 'location is a repository' message via smart server when possible (adds BzrDir.open_branchV3 verb). |
3810 |
expected_error = errors.NotBranchError( |
3811 |
path=bzrdir.root_transport.base, |
|
3812 |
detail='extra detail') |
|
3813 |
self.assertEqual(expected_error, translated_error) |
|
3814 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3815 |
def test_norepository(self): |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3816 |
bzrdir = self.make_controldir('') |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3817 |
translated_error = self.translateTuple((b'norepository',), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3818 |
bzrdir=bzrdir) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3819 |
expected_error = errors.NoRepositoryPresent(bzrdir) |
3820 |
self.assertEqual(expected_error, translated_error) |
|
3821 |
||
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3822 |
def test_LockContention(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3823 |
translated_error = self.translateTuple((b'LockContention',)) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3824 |
expected_error = errors.LockContention('(remote lock)') |
3825 |
self.assertEqual(expected_error, translated_error) |
|
3826 |
||
3827 |
def test_UnlockableTransport(self): |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
3828 |
bzrdir = self.make_controldir('') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3829 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3830 |
(b'UnlockableTransport',), bzrdir=bzrdir) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3831 |
expected_error = errors.UnlockableTransport(bzrdir.root_transport) |
3832 |
self.assertEqual(expected_error, translated_error) |
|
3833 |
||
3834 |
def test_LockFailed(self): |
|
3835 |
lock = 'str() of a server lock' |
|
3836 |
why = 'str() of why' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3837 |
translated_error = self.translateTuple( |
3838 |
(b'LockFailed', lock.encode('ascii'), why.encode('ascii'))) |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3839 |
expected_error = errors.LockFailed(lock, why) |
3840 |
self.assertEqual(expected_error, translated_error) |
|
3841 |
||
3842 |
def test_TokenMismatch(self): |
|
3843 |
token = 'a lock token' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3844 |
translated_error = self.translateTuple( |
3845 |
(b'TokenMismatch',), token=token) |
|
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3846 |
expected_error = errors.TokenMismatch(token, '(remote token)') |
3847 |
self.assertEqual(expected_error, translated_error) |
|
3848 |
||
3849 |
def test_Diverged(self): |
|
3850 |
branch = self.make_branch('a') |
|
3851 |
other_branch = self.make_branch('b') |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3852 |
translated_error = self.translateTuple( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3853 |
(b'Diverged',), branch=branch, other_branch=other_branch) |
|
3533.3.3
by Andrew Bennetts
Add unit tests for bzrlib.remote._translate_error. |
3854 |
expected_error = errors.DivergedBranches(branch, other_branch) |
3855 |
self.assertEqual(expected_error, translated_error) |
|
3856 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3857 |
def test_NotStacked(self): |
3858 |
branch = self.make_branch('') |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3859 |
translated_error = self.translateTuple((b'NotStacked',), branch=branch) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3860 |
expected_error = errors.NotStacked(branch) |
3861 |
self.assertEqual(expected_error, translated_error) |
|
3862 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3863 |
def test_ReadError_no_args(self): |
3864 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3865 |
translated_error = self.translateTuple((b'ReadError',), path=path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3866 |
expected_error = errors.ReadError(path) |
3867 |
self.assertEqual(expected_error, translated_error) |
|
3868 |
||
3869 |
def test_ReadError(self): |
|
3870 |
path = 'a path' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3871 |
translated_error = self.translateTuple( |
3872 |
(b'ReadError', path.encode('utf-8'))) |
|
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3873 |
expected_error = errors.ReadError(path) |
3874 |
self.assertEqual(expected_error, translated_error) |
|
3875 |
||
|
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
3876 |
def test_IncompatibleRepositories(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3877 |
translated_error = self.translateTuple((b'IncompatibleRepositories', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3878 |
b"repo1", b"repo2", b"details here")) |
|
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
3879 |
expected_error = errors.IncompatibleRepositories("repo1", "repo2", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3880 |
"details here") |
|
4650.2.1
by Robert Collins
Deserialise IncompatibleRepositories errors in the client, generating |
3881 |
self.assertEqual(expected_error, translated_error) |
3882 |
||
|
6969.1.1
by Jelmer Vernooij
Handle GhostRevisionsHaveNoRevno in hpss. |
3883 |
def test_GhostRevisionsHaveNoRevno(self): |
3884 |
translated_error = self.translateTuple((b'GhostRevisionsHaveNoRevno', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3885 |
b"revid1", b"revid2")) |
|
6969.1.1
by Jelmer Vernooij
Handle GhostRevisionsHaveNoRevno in hpss. |
3886 |
expected_error = errors.GhostRevisionsHaveNoRevno(b"revid1", b"revid2") |
3887 |
self.assertEqual(expected_error, translated_error) |
|
3888 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3889 |
def test_PermissionDenied_no_args(self): |
3890 |
path = 'a path' |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3891 |
translated_error = self.translateTuple((b'PermissionDenied',), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3892 |
path=path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3893 |
expected_error = errors.PermissionDenied(path) |
3894 |
self.assertEqual(expected_error, translated_error) |
|
3895 |
||
3896 |
def test_PermissionDenied_one_arg(self): |
|
3897 |
path = 'a path' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3898 |
translated_error = self.translateTuple( |
3899 |
(b'PermissionDenied', path.encode('utf-8'))) |
|
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3900 |
expected_error = errors.PermissionDenied(path) |
3901 |
self.assertEqual(expected_error, translated_error) |
|
3902 |
||
3903 |
def test_PermissionDenied_one_arg_and_context(self): |
|
3904 |
"""Given a choice between a path from the local context and a path on |
|
3905 |
the wire, _translate_error prefers the path from the local context.
|
|
3906 |
"""
|
|
3907 |
local_path = 'local path' |
|
3908 |
remote_path = 'remote path' |
|
3909 |
translated_error = self.translateTuple( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3910 |
(b'PermissionDenied', remote_path.encode('utf-8')), path=local_path) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3911 |
expected_error = errors.PermissionDenied(local_path) |
3912 |
self.assertEqual(expected_error, translated_error) |
|
3913 |
||
3914 |
def test_PermissionDenied_two_args(self): |
|
3915 |
path = 'a path' |
|
3916 |
extra = 'a string with extra info' |
|
3917 |
translated_error = self.translateTuple( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3918 |
(b'PermissionDenied', path.encode('utf-8'), extra.encode('utf-8'))) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3919 |
expected_error = errors.PermissionDenied(path, extra) |
3920 |
self.assertEqual(expected_error, translated_error) |
|
3921 |
||
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3922 |
# GZ 2011-03-02: TODO test for PermissionDenied with non-ascii 'extra'
|
3923 |
||
3924 |
def test_NoSuchFile_context_path(self): |
|
3925 |
local_path = "local path" |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3926 |
translated_error = self.translateTuple((b'ReadError', b"remote path"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3927 |
path=local_path) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3928 |
expected_error = errors.ReadError(local_path) |
3929 |
self.assertEqual(expected_error, translated_error) |
|
3930 |
||
3931 |
def test_NoSuchFile_without_context(self): |
|
3932 |
remote_path = "remote path" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3933 |
translated_error = self.translateTuple( |
3934 |
(b'ReadError', remote_path.encode('utf-8'))) |
|
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3935 |
expected_error = errors.ReadError(remote_path) |
3936 |
self.assertEqual(expected_error, translated_error) |
|
3937 |
||
3938 |
def test_ReadOnlyError(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3939 |
translated_error = self.translateTuple((b'ReadOnlyError',)) |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3940 |
expected_error = errors.TransportNotPossible("readonly transport") |
3941 |
self.assertEqual(expected_error, translated_error) |
|
3942 |
||
3943 |
def test_MemoryError(self): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3944 |
translated_error = self.translateTuple((b'MemoryError',)) |
|
5677.2.9
by Martin
Add hint to possible ways forward for user in remote MemoryError message |
3945 |
self.assertStartsWith(str(translated_error), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3946 |
"remote server out of memory") |
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3947 |
|
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3948 |
def test_generic_IndexError_no_classname(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
3949 |
err = errors.ErrorFromSmartServer( |
3950 |
(b'error', b"list index out of range")) |
|
|
5677.2.5
by Martin
Add more tests for remote._translate_error including for MemoryError handling |
3951 |
translated_error = self.translateErrorFromSmartServer(err) |
3952 |
expected_error = errors.UnknownErrorFromSmartServer(err) |
|
3953 |
self.assertEqual(expected_error, translated_error) |
|
3954 |
||
3955 |
# GZ 2011-03-02: TODO test generic non-ascii error string
|
|
3956 |
||
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3957 |
def test_generic_KeyError(self): |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3958 |
err = errors.ErrorFromSmartServer((b'error', b'KeyError', b"1")) |
|
5677.2.8
by Martin
More tests for handling of unexpected remote errors |
3959 |
translated_error = self.translateErrorFromSmartServer(err) |
3960 |
expected_error = errors.UnknownErrorFromSmartServer(err) |
|
3961 |
self.assertEqual(expected_error, translated_error) |
|
3962 |
||
|
7290.19.2
by Jelmer Vernooij
Return consist errors from Branch.get_revid and Repository.get_revid_for_revno. |
3963 |
def test_RevnoOutOfBounds(self): |
3964 |
translated_error = self.translateTuple( |
|
3965 |
((b'revno-outofbounds', 5, 0, 3)), path=b'path') |
|
|
7290.19.4
by Jelmer Vernooij
More tests. |
3966 |
expected_error = errors.RevnoOutOfBounds(5, (0, 3)) |
|
7290.19.2
by Jelmer Vernooij
Return consist errors from Branch.get_revid and Repository.get_revid_for_revno. |
3967 |
self.assertEqual(expected_error, translated_error) |
3968 |
||
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
3969 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3970 |
class TestErrorTranslationRobustness(TestErrorTranslationBase): |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
3971 |
"""Unit tests for breezy.bzr.remote._translate_error's robustness. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
3972 |
|
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3973 |
TestErrorTranslationSuccess is for cases where _translate_error can
|
3974 |
translate successfully. This class about how _translate_err behaves when
|
|
3975 |
it fails to translate: it re-raises the original error.
|
|
3976 |
"""
|
|
3977 |
||
3978 |
def test_unrecognised_server_error(self): |
|
3979 |
"""If the error code from the server is not recognised, the original |
|
3980 |
ErrorFromSmartServer is propagated unmodified.
|
|
3981 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3982 |
error_tuple = (b'An unknown error tuple',) |
|
3690.1.2
by Andrew Bennetts
Rename UntranslateableErrorFromSmartServer -> UnknownErrorFromSmartServer. |
3983 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
3984 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
3985 |
expected_error = errors.UnknownErrorFromSmartServer(server_error) |
|
|
3690.1.1
by Andrew Bennetts
Unexpected error responses from a smart server no longer cause the client to traceback. |
3986 |
self.assertEqual(expected_error, translated_error) |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3987 |
|
3988 |
def test_context_missing_a_key(self): |
|
3989 |
"""In case of a bug in the client, or perhaps an unexpected response |
|
3990 |
from a server, _translate_error returns the original error tuple from
|
|
3991 |
the server and mutters a warning.
|
|
3992 |
"""
|
|
3993 |
# To translate a NoSuchRevision error _translate_error needs a 'branch'
|
|
3994 |
# in the context dict. So let's give it an empty context dict instead
|
|
3995 |
# to exercise its error recovery.
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
3996 |
error_tuple = (b'NoSuchRevision', b'revid') |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
3997 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
3998 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
3999 |
self.assertEqual(server_error, translated_error) |
|
4000 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
4001 |
# been muttered to the log file for developer to look at.
|
|
4002 |
self.assertContainsRe( |
|
|
4794.1.15
by Robert Collins
Review feedback. |
4003 |
self.get_log(), |
|
3533.3.4
by Andrew Bennetts
Add tests for _translate_error's robustness. |
4004 |
"Missing key 'branch' in context") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
4005 |
|
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
4006 |
def test_path_missing(self): |
4007 |
"""Some translations (PermissionDenied, ReadError) can determine the |
|
4008 |
'path' variable from either the wire or the local context. If neither
|
|
4009 |
has it, then an error is raised.
|
|
4010 |
"""
|
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4011 |
error_tuple = (b'ReadError',) |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
4012 |
server_error = errors.ErrorFromSmartServer(error_tuple) |
4013 |
translated_error = self.translateErrorFromSmartServer(server_error) |
|
4014 |
self.assertEqual(server_error, translated_error) |
|
4015 |
# In addition to re-raising ErrorFromSmartServer, some debug info has
|
|
4016 |
# been muttered to the log file for developer to look at.
|
|
|
4794.1.15
by Robert Collins
Review feedback. |
4017 |
self.assertContainsRe(self.get_log(), "Missing key 'path' in context") |
|
3786.4.2
by Andrew Bennetts
Add tests and fix code to make sure ReadError and PermissionDenied are robustly handled by _translate_error. |
4018 |
|
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4019 |
|
4020 |
class TestStacking(tests.TestCaseWithTransport): |
|
4021 |
"""Tests for operations on stacked remote repositories. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
4022 |
|
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4023 |
The underlying format type must support stacking.
|
4024 |
"""
|
|
4025 |
||
4026 |
def test_access_stacked_remote(self): |
|
4027 |
# based on <http://launchpad.net/bugs/261315>
|
|
4028 |
# make a branch stacked on another repository containing an empty
|
|
4029 |
# revision, then open it over hpss - we should be able to see that
|
|
4030 |
# revision.
|
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4031 |
base_builder = self.make_branch_builder('base', format='1.9') |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4032 |
base_builder.start_series() |
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
4033 |
base_revid = base_builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4034 |
[('add', ('', None, 'directory', None))], |
4035 |
'message', revision_id=b'rev-id') |
|
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4036 |
base_builder.finish_series() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4037 |
stacked_branch = self.make_branch('stacked', format='1.9') |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4038 |
stacked_branch.set_stacked_on_url('../base') |
4039 |
# start a server looking at this
|
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
4040 |
smart_server = test_server.SmartTCPServer_for_testing() |
|
4659.1.3
by Robert Collins
Review feedback. |
4041 |
self.start_server(smart_server) |
|
3691.2.2
by Martin Pool
Fix some problems in access to stacked repositories over hpss (#261315) |
4042 |
remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked') |
4043 |
# can get its branch and repository
|
|
4044 |
remote_branch = remote_bzrdir.open_branch() |
|
4045 |
remote_repo = remote_branch.repository |
|
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
4046 |
remote_repo.lock_read() |
4047 |
try: |
|
4048 |
# it should have an appropriate fallback repository, which should also
|
|
4049 |
# be a RemoteRepository
|
|
|
4288.1.2
by Robert Collins
Create a server verb for doing BzrDir.get_config() |
4050 |
self.assertLength(1, remote_repo._fallback_repositories) |
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
4051 |
self.assertIsInstance(remote_repo._fallback_repositories[0], |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4052 |
RemoteRepository) |
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
4053 |
# and it has the revision committed to the underlying repository;
|
4054 |
# these have varying implementations so we try several of them
|
|
4055 |
self.assertTrue(remote_repo.has_revisions([base_revid])) |
|
4056 |
self.assertTrue(remote_repo.has_revision(base_revid)) |
|
4057 |
self.assertEqual(remote_repo.get_revision(base_revid).message, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4058 |
'message') |
|
3691.2.6
by Martin Pool
Disable RemoteBranch stacking, but get get_stacked_on_url working, and passing back exceptions |
4059 |
finally: |
4060 |
remote_repo.unlock() |
|
|
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
4061 |
|
|
3835.1.7
by Aaron Bentley
Updates from review |
4062 |
def prepare_stacked_remote_branch(self): |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4063 |
"""Get stacked_upon and stacked branches with content in each.""" |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4064 |
self.setup_smart_server_with_call_log() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4065 |
tree1 = self.make_branch_and_tree('tree1', format='1.9') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
4066 |
tree1.commit('rev1', rev_id=b'rev1') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
4067 |
tree2 = tree1.branch.controldir.sprout('tree2', stacked=True |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4068 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
4069 |
local_tree = tree2.branch.create_checkout('local') |
4070 |
local_tree.commit('local changes make me feel good.') |
|
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4071 |
branch2 = Branch.open(self.get_url('tree2')) |
|
3835.1.2
by Aaron Bentley
Add tests for get_parent_map |
4072 |
branch2.lock_read() |
4073 |
self.addCleanup(branch2.unlock) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4074 |
return tree1.branch, branch2 |
|
3835.1.7
by Aaron Bentley
Updates from review |
4075 |
|
4076 |
def test_stacked_get_parent_map(self): |
|
4077 |
# the public implementation of get_parent_map obeys stacking
|
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4078 |
_, branch = self.prepare_stacked_remote_branch() |
|
3835.1.7
by Aaron Bentley
Updates from review |
4079 |
repo = branch.repository |
|
7045.4.21
by Jelmer Vernooij
Fix some msgeditor tests. |
4080 |
self.assertEqual({b'rev1'}, set(repo.get_parent_map([b'rev1']))) |
|
3835.1.7
by Aaron Bentley
Updates from review |
4081 |
|
|
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
4082 |
def test_unstacked_get_parent_map(self): |
4083 |
# _unstacked_provider.get_parent_map ignores stacking
|
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4084 |
_, branch = self.prepare_stacked_remote_branch() |
|
3835.1.10
by Aaron Bentley
Move CachingExtraParentsProvider to Graph |
4085 |
provider = branch.repository._unstacked_provider |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4086 |
self.assertEqual(set(), set(provider.get_parent_map([b'rev1']))) |
|
3834.3.3
by John Arbash Meinel
Merge bzr.dev, resolve conflict in tests. |
4087 |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4088 |
def fetch_stream_to_rev_order(self, stream): |
4089 |
result = [] |
|
4090 |
for kind, substream in stream: |
|
4091 |
if not kind == 'revisions': |
|
4092 |
list(substream) |
|
4093 |
else: |
|
4094 |
for content in substream: |
|
4095 |
result.append(content.key[-1]) |
|
4096 |
return result |
|
4097 |
||
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4098 |
def get_ordered_revs(self, format, order, branch_factory=None): |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4099 |
"""Get a list of the revisions in a stream to format format. |
4100 |
||
4101 |
:param format: The format of the target.
|
|
4102 |
:param order: the order that target should have requested.
|
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4103 |
:param branch_factory: A callable to create a trunk and stacked branch
|
4104 |
to fetch from. If none, self.prepare_stacked_remote_branch is used.
|
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4105 |
:result: The revision ids in the stream, in the order seen,
|
4106 |
the topological order of revisions in the source.
|
|
4107 |
"""
|
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
4108 |
unordered_format = controldir.format_registry.get(format)() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4109 |
target_repository_format = unordered_format.repository_format |
4110 |
# Cross check
|
|
4111 |
self.assertEqual(order, target_repository_format._fetch_order) |
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4112 |
if branch_factory is None: |
4113 |
branch_factory = self.prepare_stacked_remote_branch |
|
4114 |
_, stacked = branch_factory() |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4115 |
source = stacked.repository._get_source(target_repository_format) |
4116 |
tip = stacked.last_revision() |
|
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
4117 |
stacked.repository._ensure_real() |
4118 |
graph = stacked.repository.get_graph() |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
4119 |
revs = [r for (r, ps) in graph.iter_ancestry([tip]) |
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
4120 |
if r != NULL_REVISION] |
4121 |
revs.reverse() |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
4122 |
search = vf_search.PendingAncestryResult([tip], stacked.repository) |
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4123 |
self.reset_smart_call_log() |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4124 |
stream = source.get_stream(search) |
4125 |
# We trust that if a revision is in the stream the rest of the new
|
|
4126 |
# content for it is too, as per our main fetch tests; here we are
|
|
4127 |
# checking that the revisions are actually included at all, and their
|
|
4128 |
# order.
|
|
4129 |
return self.fetch_stream_to_rev_order(stream), revs |
|
4130 |
||
4131 |
def test_stacked_get_stream_unordered(self): |
|
4132 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4133 |
# unordered yields the full data from both stacked and stacked upon
|
|
4134 |
# sources.
|
|
4135 |
rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered') |
|
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4136 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
4137 |
# Getting unordered results should have made a streaming data request
|
|
4138 |
# from the server, then one from the backing branch.
|
|
4139 |
self.assertLength(2, self.hpss_calls) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4140 |
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4141 |
def test_stacked_on_stacked_get_stream_unordered(self): |
4142 |
# Repository._get_source.get_stream() from a stacked repository which
|
|
4143 |
# is itself stacked yields the full data from all three sources.
|
|
4144 |
def make_stacked_stacked(): |
|
4145 |
_, stacked = self.prepare_stacked_remote_branch() |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
4146 |
tree = stacked.controldir.sprout('tree3', stacked=True |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4147 |
).open_workingtree() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
4148 |
local_tree = tree.branch.create_checkout('local-tree3') |
4149 |
local_tree.commit('more local changes are better') |
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4150 |
branch = Branch.open(self.get_url('tree3')) |
4151 |
branch.lock_read() |
|
|
4857.2.3
by John Arbash Meinel
Found the failed-to-unlocked branches in test_remote. |
4152 |
self.addCleanup(branch.unlock) |
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4153 |
return None, branch |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
4154 |
rev_ord, expected_revs = self.get_ordered_revs( |
4155 |
'1.9', 'unordered', branch_factory=make_stacked_stacked) |
|
|
4577.1.1
by Robert Collins
Fix fetching from smart servers where there is a chain of stacked repositories rather than a single stacking point. (Robert Collins, bug #406597) |
4156 |
self.assertEqual(set(expected_revs), set(rev_ord)) |
4157 |
# Getting unordered results should have made a streaming data request
|
|
4158 |
# from the server, and one from each backing repo
|
|
4159 |
self.assertLength(3, self.hpss_calls) |
|
4160 |
||
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4161 |
def test_stacked_get_stream_topological(self): |
4162 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4163 |
# topological sorting yields the full data from both stacked and
|
|
4164 |
# stacked upon sources in topological order.
|
|
4165 |
rev_ord, expected_revs = self.get_ordered_revs('knit', 'topological') |
|
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4166 |
self.assertEqual(expected_revs, rev_ord) |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
4167 |
# Getting topological sort requires VFS calls still - one of which is
|
4168 |
# pushing up from the bound branch.
|
|
|
5972.3.25
by Jelmer Vernooij
Fix another use of get_ancestry. |
4169 |
self.assertLength(14, self.hpss_calls) |
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4170 |
|
4171 |
def test_stacked_get_stream_groupcompress(self): |
|
4172 |
# Repository._get_source.get_stream() from a stacked repository with
|
|
4173 |
# groupcompress sorting yields the full data from both stacked and
|
|
4174 |
# stacked upon sources in groupcompress order.
|
|
4175 |
raise tests.TestSkipped('No groupcompress ordered format available') |
|
4176 |
rev_ord, expected_revs = self.get_ordered_revs('dev5', 'groupcompress') |
|
|
4152.1.2
by Robert Collins
Add streaming from a stacked branch when the sort order is compatible with doing so. |
4177 |
self.assertEqual(expected_revs, reversed(rev_ord)) |
4178 |
# Getting unordered results should have made a streaming data request
|
|
4179 |
# from the backing branch, and one from the stacked on branch.
|
|
4180 |
self.assertLength(2, self.hpss_calls) |
|
|
4152.1.1
by Robert Collins
Add specific tests for fetch streaming in the bzr protocol client. |
4181 |
|
|
4332.2.1
by Robert Collins
Fix bug 360791 by not raising an error when a smart server is asked for more content than it has locally; the client is assumed to be monitoring what it gets. |
4182 |
def test_stacked_pull_more_than_stacking_has_bug_360791(self): |
4183 |
# When pulling some fixed amount of content that is more than the
|
|
4184 |
# source has (because some is coming from a fallback branch, no error
|
|
4185 |
# should be received. This was reported as bug 360791.
|
|
4186 |
# Need three branches: a trunk, a stacked branch, and a preexisting
|
|
4187 |
# branch pulling content from stacked and trunk.
|
|
4188 |
self.setup_smart_server_with_call_log() |
|
4189 |
trunk = self.make_branch_and_tree('trunk', format="1.9-rich-root") |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
4190 |
trunk.commit('start') |
|
4332.2.1
by Robert Collins
Fix bug 360791 by not raising an error when a smart server is asked for more content than it has locally; the client is assumed to be monitoring what it gets. |
4191 |
stacked_branch = trunk.branch.create_clone_on_transport( |
4192 |
self.get_transport('stacked'), stacked_on=trunk.branch.base) |
|
4193 |
local = self.make_branch('local', format='1.9-rich-root') |
|
4194 |
local.repository.fetch(stacked_branch.repository, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4195 |
stacked_branch.last_revision()) |
|
4332.2.1
by Robert Collins
Fix bug 360791 by not raising an error when a smart server is asked for more content than it has locally; the client is assumed to be monitoring what it gets. |
4196 |
|
|
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
4197 |
|
4198 |
class TestRemoteBranchEffort(tests.TestCaseWithTransport): |
|
4199 |
||
4200 |
def setUp(self): |
|
4201 |
super(TestRemoteBranchEffort, self).setUp() |
|
4202 |
# Create a smart server that publishes whatever the backing VFS server
|
|
4203 |
# does.
|
|
|
5017.3.28
by Vincent Ladeuil
selftest -s bt.test_remote passing |
4204 |
self.smart_server = test_server.SmartTCPServer_for_testing() |
|
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
4205 |
self.start_server(self.smart_server, self.get_server()) |
|
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
4206 |
# Log all HPSS calls into self.hpss_calls.
|
4207 |
_SmartClient.hooks.install_named_hook( |
|
4208 |
'call', self.capture_hpss_call, None) |
|
4209 |
self.hpss_calls = [] |
|
4210 |
||
4211 |
def capture_hpss_call(self, params): |
|
4212 |
self.hpss_calls.append(params.method) |
|
4213 |
||
4214 |
def test_copy_content_into_avoids_revision_history(self): |
|
4215 |
local = self.make_branch('local') |
|
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4216 |
builder = self.make_branch_builder('remote') |
4217 |
builder.build_commit(message="Commit.") |
|
|
3834.3.2
by Andrew Bennetts
Preserve BzrBranch5's _synchronize_history code without affecting Branch or BzrBranch7; add effort test for RemoteBranch.copy_content_into. |
4218 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
4219 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4220 |
local.repository.fetch(remote_branch.repository) |
|
4221 |
self.hpss_calls = [] |
|
4222 |
remote_branch.copy_content_into(local) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4223 |
self.assertFalse(b'Branch.revision_history' in self.hpss_calls) |
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4224 |
|
|
5539.2.6
by Andrew Bennetts
Better test name. |
4225 |
def test_fetch_everything_needs_just_one_call(self): |
|
5539.2.5
by Andrew Bennetts
Add test to test_remote, fix another shallow bug. |
4226 |
local = self.make_branch('local') |
4227 |
builder = self.make_branch_builder('remote') |
|
4228 |
builder.build_commit(message="Commit.") |
|
4229 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
|
4230 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4231 |
self.hpss_calls = [] |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4232 |
local.repository.fetch( |
4233 |
remote_branch.repository, |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
4234 |
fetch_spec=vf_search.EverythingResult(remote_branch.repository)) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4235 |
self.assertEqual([b'Repository.get_stream_1.19'], self.hpss_calls) |
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4236 |
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4237 |
def override_verb(self, verb_name, verb): |
4238 |
request_handlers = request.request_handlers |
|
4239 |
orig_verb = request_handlers.get(verb_name) |
|
|
6206.1.11
by Jelmer Vernooij
Preserve info when restoring verbs after disabling/overriding. |
4240 |
orig_info = request_handlers.get_info(verb_name) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4241 |
request_handlers.register(verb_name, verb, override_existing=True) |
4242 |
self.addCleanup(request_handlers.register, verb_name, orig_verb, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4243 |
override_existing=True, info=orig_info) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4244 |
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4245 |
def test_fetch_everything_backwards_compat(self): |
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4246 |
"""Can fetch with EverythingResult even with pre 2.4 servers. |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4247 |
|
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4248 |
Pre-2.4 do not support 'everything' searches with the
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4249 |
Repository.get_stream_1.19 verb.
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4250 |
"""
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4251 |
verb_log = [] |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4252 |
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4253 |
class OldGetStreamVerb(SmartServerRepositoryGetStream_1_19): |
4254 |
"""A version of the Repository.get_stream_1.19 verb patched to |
|
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
4255 |
reject 'everything' searches the way 2.3 and earlier do.
|
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4256 |
"""
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4257 |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4258 |
def recreate_search(self, repository, search_bytes, |
4259 |
discard_excess=False): |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4260 |
verb_log.append(search_bytes.split(b'\n', 1)[0]) |
4261 |
if search_bytes == b'everything': |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4262 |
return (None, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4263 |
request.FailedSmartServerResponse((b'BadSearch',))) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4264 |
return super(OldGetStreamVerb, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4265 |
self).recreate_search(repository, search_bytes, |
4266 |
discard_excess=discard_excess) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4267 |
self.override_verb(b'Repository.get_stream_1.19', OldGetStreamVerb) |
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4268 |
local = self.make_branch('local') |
4269 |
builder = self.make_branch_builder('remote') |
|
4270 |
builder.build_commit(message="Commit.") |
|
4271 |
remote_branch_url = self.smart_server.get_url() + 'remote' |
|
4272 |
remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch() |
|
4273 |
self.hpss_calls = [] |
|
|
6015.5.1
by Vincent Ladeuil
Merge 2.3 into 2.4 |
4274 |
local.repository.fetch( |
4275 |
remote_branch.repository, |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
4276 |
fetch_spec=vf_search.EverythingResult(remote_branch.repository)) |
|
5536.2.7
by Andrew Bennetts
Fix test_fetch_everything_backwards_compat to actually test what it is intended to test. |
4277 |
# make sure the overridden verb was used
|
4278 |
self.assertLength(1, verb_log) |
|
4279 |
# more than one HPSS call is needed, but because it's a VFS callback
|
|
4280 |
# its hard to predict exactly how many.
|
|
4281 |
self.assertTrue(len(self.hpss_calls) > 1) |
|
|
5539.2.13
by Andrew Bennetts
Add a test for compatibility with pre-2.3 servers. |
4282 |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4283 |
|
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4284 |
class TestUpdateBoundBranchWithModifiedBoundLocation( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4285 |
tests.TestCaseWithTransport): |
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4286 |
"""Ensure correct handling of bound_location modifications. |
4287 |
||
4288 |
This is tested against a smart server as http://pad.lv/786980 was about a
|
|
4289 |
ReadOnlyError (write attempt during a read-only transaction) which can only
|
|
4290 |
happen in this context.
|
|
4291 |
"""
|
|
4292 |
||
4293 |
def setUp(self): |
|
4294 |
super(TestUpdateBoundBranchWithModifiedBoundLocation, self).setUp() |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4295 |
self.transport_server = test_server.SmartTCPServer_for_testing |
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4296 |
|
4297 |
def make_master_and_checkout(self, master_name, checkout_name): |
|
4298 |
# Create the master branch and its associated checkout
|
|
4299 |
self.master = self.make_branch_and_tree(master_name) |
|
4300 |
self.checkout = self.master.branch.create_checkout(checkout_name) |
|
4301 |
# Modify the master branch so there is something to update
|
|
4302 |
self.master.commit('add stuff') |
|
4303 |
self.last_revid = self.master.commit('even more stuff') |
|
4304 |
self.bound_location = self.checkout.branch.get_bound_location() |
|
4305 |
||
4306 |
def assertUpdateSucceeds(self, new_location): |
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
4307 |
self.checkout.branch.set_bound_location(new_location) |
4308 |
self.checkout.update() |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
4309 |
self.assertEqual(self.last_revid, self.checkout.last_revision()) |
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4310 |
|
4311 |
def test_without_final_slash(self): |
|
4312 |
self.make_master_and_checkout('master', 'checkout') |
|
|
5609.50.1
by Vincent Ladeuil
Be more tolerant about ``bound_location`` from config files |
4313 |
# For unclear reasons some users have a bound_location without a final
|
4314 |
# '/', simulate that by forcing such a value
|
|
|
5609.50.4
by Vincent Ladeuil
Add more tests for accepted bound_location variations. |
4315 |
self.assertEndsWith(self.bound_location, '/') |
4316 |
self.assertUpdateSucceeds(self.bound_location.rstrip('/')) |
|
4317 |
||
4318 |
def test_plus_sign(self): |
|
4319 |
self.make_master_and_checkout('+master', 'checkout') |
|
4320 |
self.assertUpdateSucceeds(self.bound_location.replace('%2B', '+', 1)) |
|
4321 |
||
4322 |
def test_tilda(self): |
|
4323 |
# Embed ~ in the middle of the path just to avoid any $HOME
|
|
4324 |
# interpretation
|
|
4325 |
self.make_master_and_checkout('mas~ter', 'checkout') |
|
4326 |
self.assertUpdateSucceeds(self.bound_location.replace('%2E', '~', 1)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4327 |
|
4328 |
||
4329 |
class TestWithCustomErrorHandler(RemoteBranchTestCase): |
|
4330 |
||
4331 |
def test_no_context(self): |
|
4332 |
class OutOfCoffee(errors.BzrError): |
|
4333 |
"""A dummy exception for testing.""" |
|
4334 |
||
4335 |
def __init__(self, urgency): |
|
4336 |
self.urgency = urgency |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4337 |
remote.no_context_error_translators.register(b"OutOfCoffee", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4338 |
lambda err: OutOfCoffee(err.error_args[0])) |
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4339 |
transport = MemoryTransport() |
4340 |
client = FakeClient(transport.base) |
|
4341 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4342 |
b'Branch.get_stacked_on_url', (b'quack/',), |
4343 |
b'error', (b'NotStacked',)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4344 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4345 |
b'Branch.last_revision_info', |
4346 |
(b'quack/',), |
|
4347 |
b'error', (b'OutOfCoffee', b'low')) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4348 |
transport.mkdir('quack') |
4349 |
transport = transport.clone('quack') |
|
4350 |
branch = self.make_remote_branch(transport, client) |
|
4351 |
self.assertRaises(OutOfCoffee, branch.last_revision_info) |
|
4352 |
self.assertFinished(client) |
|
4353 |
||
4354 |
def test_with_context(self): |
|
4355 |
class OutOfTea(errors.BzrError): |
|
4356 |
def __init__(self, branch, urgency): |
|
4357 |
self.branch = branch |
|
4358 |
self.urgency = urgency |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4359 |
remote.error_translators.register(b"OutOfTea", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4360 |
lambda err, find, path: OutOfTea( |
4361 |
err.error_args[0].decode( |
|
4362 |
'utf-8'), |
|
4363 |
find("branch"))) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4364 |
transport = MemoryTransport() |
4365 |
client = FakeClient(transport.base) |
|
4366 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4367 |
b'Branch.get_stacked_on_url', (b'quack/',), |
4368 |
b'error', (b'NotStacked',)) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4369 |
client.add_expected_call( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4370 |
b'Branch.last_revision_info', |
4371 |
(b'quack/',), |
|
4372 |
b'error', (b'OutOfTea', b'low')) |
|
|
6284.1.1
by Jelmer Vernooij
Allow registering custom error handlers in the HPSS client. |
4373 |
transport.mkdir('quack') |
4374 |
transport = transport.clone('quack') |
|
4375 |
branch = self.make_remote_branch(transport, client) |
|
4376 |
self.assertRaises(OutOfTea, branch.last_revision_info) |
|
4377 |
self.assertFinished(client) |
|
|
6305.2.1
by Jelmer Vernooij
add remote call for Repository.pack. |
4378 |
|
4379 |
||
4380 |
class TestRepositoryPack(TestRemoteRepository): |
|
4381 |
||
4382 |
def test_pack(self): |
|
4383 |
transport_path = 'quack' |
|
4384 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4385 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4386 |
b'Repository.lock_write', (b'quack/', b''), |
4387 |
b'success', (b'ok', b'token')) |
|
4388 |
client.add_expected_call( |
|
4389 |
b'Repository.pack', (b'quack/', b'token', b'False'), |
|
4390 |
b'success', (b'ok',), ) |
|
4391 |
client.add_expected_call( |
|
4392 |
b'Repository.unlock', (b'quack/', b'token'), |
|
4393 |
b'success', (b'ok', )) |
|
|
6305.2.1
by Jelmer Vernooij
add remote call for Repository.pack. |
4394 |
repo.pack() |
4395 |
||
4396 |
def test_pack_with_hint(self): |
|
4397 |
transport_path = 'quack' |
|
4398 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4399 |
client.add_expected_call( |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4400 |
b'Repository.lock_write', (b'quack/', b''), |
4401 |
b'success', (b'ok', b'token')) |
|
4402 |
client.add_expected_call( |
|
4403 |
b'Repository.pack', (b'quack/', b'token', b'False'), |
|
4404 |
b'success', (b'ok',), ) |
|
4405 |
client.add_expected_call( |
|
4406 |
b'Repository.unlock', (b'quack/', b'token', b'False'), |
|
4407 |
b'success', (b'ok', )) |
|
|
7078.7.2
by Jelmer Vernooij
Fix remote pack test. |
4408 |
repo.pack(['hinta', 'hintb']) |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4409 |
|
4410 |
||
|
6282.6.9
by Jelmer Vernooij
More tests. |
4411 |
class TestRepositoryIterInventories(TestRemoteRepository): |
4412 |
"""Test Repository.iter_inventories.""" |
|
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4413 |
|
4414 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4415 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4416 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4417 |
|
|
6282.6.9
by Jelmer Vernooij
More tests. |
4418 |
def test_single_empty(self): |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4419 |
transport_path = 'quack' |
4420 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
4421 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
4422 |
repo._format = fmt |
|
6282.6.43
by Jelmer Vernooij
Fix stream name. |
4423 |
stream = [('inventory-deltas', [ |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4424 |
versionedfile.FulltextContentFactory(b'somerevid', None, None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4425 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
6282.6.8
by Jelmer Vernooij
Adjust _iter_inventories contract slightly, don't raise NoSuchRevision immediately |
4426 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4427 |
b'VersionedFileRepository.get_inventories', ( |
4428 |
b'quack/', b'unordered'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4429 |
b'success', (b'ok', ), |
|
6282.6.37
by Jelmer Vernooij
Cope with empty results. |
4430 |
_stream_to_byte_stream(stream, fmt)) |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4431 |
ret = list(repo.iter_inventories([b"somerevid"])) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4432 |
self.assertLength(1, ret) |
4433 |
inv = ret[0] |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4434 |
self.assertEqual(b"somerevid", inv.revision_id) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4435 |
|
4436 |
def test_empty(self): |
|
4437 |
transport_path = 'quack' |
|
4438 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4439 |
ret = list(repo.iter_inventories([])) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
4440 |
self.assertEqual(ret, []) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4441 |
|
4442 |
def test_missing(self): |
|
4443 |
transport_path = 'quack' |
|
4444 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4445 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4446 |
b'VersionedFileRepository.get_inventories', ( |
4447 |
b'quack/', b'unordered'), |
|
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4448 |
b'success', (b'ok', ), iter([])) |
|
6282.6.9
by Jelmer Vernooij
More tests. |
4449 |
self.assertRaises(errors.NoSuchRevision, list, repo.iter_inventories( |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
4450 |
[b"somerevid"])) |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4451 |
|
4452 |
||
4453 |
class TestRepositoryRevisionTreeArchive(TestRemoteRepository): |
|
4454 |
"""Test Repository.iter_inventories.""" |
|
4455 |
||
4456 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4457 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
4458 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
4459 |
||
4460 |
def test_simple(self): |
|
4461 |
transport_path = 'quack' |
|
4462 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4463 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
4464 |
repo._format = fmt |
|
4465 |
stream = [('inventory-deltas', [ |
|
4466 |
versionedfile.FulltextContentFactory(b'somerevid', None, None, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4467 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4468 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4469 |
b'VersionedFileRepository.get_inventories', ( |
4470 |
b'quack/', b'unordered'), |
|
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4471 |
b'success', (b'ok', ), |
4472 |
_stream_to_byte_stream(stream, fmt)) |
|
4473 |
f = BytesIO() |
|
4474 |
with tarfile.open(mode='w', fileobj=f) as tf: |
|
4475 |
info = tarfile.TarInfo('somefile') |
|
4476 |
info.mtime = 432432 |
|
4477 |
contents = b'some data' |
|
4478 |
info.type = tarfile.REGTYPE |
|
4479 |
info.mode = 0o644 |
|
4480 |
info.size = len(contents) |
|
4481 |
tf.addfile(info, BytesIO(contents)) |
|
4482 |
client.add_expected_call( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4483 |
b'Repository.revision_archive', (b'quack/', |
4484 |
b'somerevid', b'tar', b'foo.tar', b'', b'', None), |
|
|
6968.5.7
by Jelmer Vernooij
Add client side test. |
4485 |
b'success', (b'ok', ), |
4486 |
f.getvalue()) |
|
4487 |
tree = repo.revision_tree(b'somerevid') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4488 |
self.assertEqual(f.getvalue(), b''.join( |
4489 |
tree.archive('tar', 'foo.tar'))) |
|
|
6997.6.5
by Jelmer Vernooij
Add tests. |
4490 |
|
4491 |
||
4492 |
class TestRepositoryAnnotate(TestRemoteRepository): |
|
4493 |
"""Test RemoteRevisionTree.annotate..""" |
|
4494 |
||
4495 |
def _serialize_inv_delta(self, old_name, new_name, delta): |
|
4496 |
serializer = inventory_delta.InventoryDeltaSerializer(True, False) |
|
4497 |
return b"".join(serializer.delta_to_lines(old_name, new_name, delta)) |
|
4498 |
||
4499 |
def test_simple(self): |
|
4500 |
transport_path = 'quack' |
|
4501 |
repo, client = self.setup_fake_client_and_repository(transport_path) |
|
4502 |
fmt = controldir.format_registry.get('2a')().repository_format |
|
4503 |
repo._format = fmt |
|
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
4504 |
stream = [ |
4505 |
('inventory-deltas', [ |
|
4506 |
versionedfile.FulltextContentFactory( |
|
4507 |
b'somerevid', None, None, |
|
4508 |
self._serialize_inv_delta(b'null:', b'somerevid', []))])] |
|
|
6997.6.5
by Jelmer Vernooij
Add tests. |
4509 |
client.add_expected_call( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
4510 |
b'VersionedFileRepository.get_inventories', ( |
4511 |
b'quack/', b'unordered'), |
|
|
6997.6.5
by Jelmer Vernooij
Add tests. |
4512 |
b'success', (b'ok', ), |
4513 |
_stream_to_byte_stream(stream, fmt)) |
|
4514 |
client.add_expected_call( |
|
4515 |
b'Repository.annotate_file_revision', |
|
4516 |
(b'quack/', b'somerevid', b'filename', b'', b'current:'), |
|
4517 |
b'success', (b'ok', ), |
|
4518 |
bencode.bencode([[b'baserevid', b'line 1\n'], |
|
4519 |
[b'somerevid', b'line2\n']])) |
|
4520 |
tree = repo.revision_tree(b'somerevid') |
|
4521 |
self.assertEqual([ |
|
4522 |
(b'baserevid', b'line 1\n'), |
|
4523 |
(b'somerevid', b'line2\n')], |
|
4524 |
list(tree.annotate_iter('filename'))) |
|
|
7449.2.3
by Jelmer Vernooij
Add client support. |
4525 |
|
4526 |
||
4527 |
class TestBranchGetAllReferenceInfo(RemoteBranchTestCase): |
|
4528 |
||
4529 |
def test_get_all_reference_info(self): |
|
4530 |
transport = MemoryTransport() |
|
4531 |
client = FakeClient(transport.base) |
|
4532 |
client.add_expected_call( |
|
4533 |
b'Branch.get_stacked_on_url', (b'quack/',), |
|
4534 |
b'error', (b'NotStacked',)) |
|
4535 |
client.add_expected_call( |
|
4536 |
b'Branch.get_all_reference_info', (b'quack/',), |
|
4537 |
b'success', (b'ok',), bencode.bencode([ |
|
|
7449.2.8
by Jelmer Vernooij
Merge storing of reference information by file id. |
4538 |
(b'file-id', b'https://www.example.com/', b'')])) |
|
7449.2.3
by Jelmer Vernooij
Add client support. |
4539 |
transport.mkdir('quack') |
4540 |
transport = transport.clone('quack') |
|
4541 |
branch = self.make_remote_branch(transport, client) |
|
4542 |
result = branch._get_all_reference_info() |
|
4543 |
self.assertFinished(client) |
|
|
7449.2.8
by Jelmer Vernooij
Merge storing of reference information by file id. |
4544 |
self.assertEqual({b'file-id': ('https://www.example.com/', None)}, result) |