bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
1 |
# Copyright (C) 2008 Canonical Ltd
|
|
0.152.1
by Vincent Ladeuil
Empty shell |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
17 |
import os |
|
0.152.46
by Vincent Ladeuil
Handle x mode bit for files and provides default mode bits for |
18 |
import stat |
|
0.152.32
by Vincent Ladeuil
Restore verbose as the default mode. |
19 |
import sys |
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
20 |
|
21 |
||
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
22 |
from bzrlib import ( |
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
23 |
branch, |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
24 |
bzrdir, |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
25 |
errors, |
|
0.152.19
by Vincent Ladeuil
Handle kind_change. Trivial implementation, blocked by bug #205636. |
26 |
osutils, |
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
27 |
remote, |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
28 |
revisionspec, |
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
29 |
tests, |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
30 |
transport, |
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
31 |
workingtree, |
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
32 |
)
|
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
33 |
from bzrlib.smart import server as smart_server |
34 |
||
35 |
from bzrlib.tests import ( |
|
36 |
test_transport_implementations, |
|
37 |
branch_implementations, |
|
38 |
)
|
|
39 |
||
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
40 |
|
|
0.155.4
by James Westby
Add the groundwork for --auto that enables the hook for a branch. |
41 |
from bzrlib.plugins.upload import cmd_upload, BzrUploader, get_upload_auto |
|
0.152.1
by Vincent Ladeuil
Empty shell |
42 |
|
43 |
||
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
44 |
class TransportAdapter( |
45 |
test_transport_implementations.TransportTestProviderAdapter): |
|
46 |
"""A tool to generate a suite testing all transports for a single test. |
|
47 |
||
48 |
We restrict the transports to the ones we want to support.
|
|
49 |
"""
|
|
50 |
||
51 |
def _test_permutations(self): |
|
52 |
"""Return a list of the klass, server_factory pairs to test.""" |
|
53 |
result = [] |
|
54 |
transport_modules =['bzrlib.transport.ftp', |
|
55 |
'bzrlib.transport.sftp'] |
|
56 |
for module in transport_modules: |
|
57 |
try: |
|
58 |
permutations = self.get_transport_test_permutations( |
|
59 |
reduce(getattr, (module).split('.')[1:], |
|
60 |
__import__(module))) |
|
61 |
for (klass, server_factory) in permutations: |
|
62 |
scenario = (server_factory.__name__, |
|
63 |
{"transport_class":klass, |
|
64 |
"transport_server":server_factory}) |
|
65 |
result.append(scenario) |
|
66 |
except errors.DependencyNotPresent, e: |
|
67 |
# Continue even if a dependency prevents us
|
|
68 |
# from adding this test
|
|
69 |
pass
|
|
|
0.152.48
by Vincent Ladeuil
Plug tests against proftpd if the local_test_sever plugin is |
70 |
try: |
71 |
import bzrlib.plugins.local_test_server |
|
72 |
from bzrlib.plugins.local_test_server import test_server |
|
73 |
if False: |
|
74 |
# XXX: Disable since we can't get chmod working for anonymous
|
|
75 |
# user
|
|
76 |
scenario = ('vsftpd', |
|
77 |
{'transport_class': test_server.FtpTransport, |
|
78 |
'transport_server': test_server.Vsftpd, |
|
79 |
})
|
|
80 |
result.append(scenario) |
|
81 |
if test_server.ProftpdFeature().available(): |
|
82 |
scenario = ('proftpd', |
|
83 |
{'transport_class': test_server.FtpTransport, |
|
84 |
'transport_server': test_server.Proftpd, |
|
85 |
})
|
|
86 |
result.append(scenario) |
|
87 |
except ImportError: |
|
88 |
pass
|
|
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
89 |
return result |
90 |
||
91 |
||
92 |
def load_tests(standard_tests, module, loader): |
|
93 |
"""Multiply tests for tranport implementations.""" |
|
94 |
result = loader.suiteClass() |
|
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
95 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
96 |
is_testing_for_transports = tests.condition_isinstance( |
97 |
(TestFullUpload, |
|
98 |
TestIncrementalUpload,)) |
|
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
99 |
transport_adapter = TransportAdapter() |
100 |
||
101 |
is_testing_for_branches = tests.condition_isinstance( |
|
102 |
(TestBranchUploadLocations,)) |
|
103 |
# Generate a list of branch formats and their associated bzrdir formats to
|
|
104 |
# use.
|
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
105 |
# XXX: This was copied from bzrlib.tests.branch_implementations.tests_suite
|
106 |
# and need to be shared in a better way.
|
|
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
107 |
combinations = [(format, format._matchingbzrdir) for format in |
108 |
branch.BranchFormat._formats.values() + branch._legacy_formats] |
|
109 |
BTPA = branch_implementations.BranchTestProviderAdapter |
|
110 |
branch_adapter = BTPA( |
|
111 |
# None here will cause the default vfs transport server to be used.
|
|
112 |
None, |
|
113 |
# None here will cause a readonly decorator to be created
|
|
114 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
115 |
None, |
|
116 |
combinations) |
|
117 |
branch_adapter_for_ss = BTPA( |
|
118 |
smart_server.SmartTCPServer_for_testing, |
|
119 |
smart_server.ReadonlySmartTCPServer_for_testing, |
|
120 |
[(remote.RemoteBranchFormat(), remote.RemoteBzrDirFormat())], |
|
121 |
# XXX: Report to bzr list, this parameter is not used in the
|
|
122 |
# constructor
|
|
123 |
||
124 |
# MemoryServer
|
|
125 |
)
|
|
126 |
||
127 |
for test_class in tests.iter_suite_tests(standard_tests): |
|
128 |
# Each test class is either standalone or testing for some combination
|
|
129 |
# of transport or branch. Use the right adpater (or none) depending on
|
|
130 |
# the class.
|
|
131 |
if is_testing_for_transports(test_class): |
|
132 |
result.addTests(transport_adapter.adapt(test_class)) |
|
133 |
elif is_testing_for_branches(test_class): |
|
134 |
result.addTests(branch_adapter.adapt(test_class)) |
|
135 |
result.addTests(branch_adapter_for_ss.adapt(test_class)) |
|
136 |
else: |
|
137 |
result.addTest(test_class) |
|
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
138 |
return result |
139 |
||
140 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
141 |
class TestUploadMixin(object): |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
142 |
"""Helper class to share tests between full and incremental uploads. |
143 |
||
144 |
This class also provides helpers to simplify test writing. The emphasis is
|
|
145 |
on easy test writing, so each tree modification is committed. This doesn't
|
|
146 |
preclude writing tests spawning several revisions to upload more complex
|
|
147 |
changes.
|
|
148 |
"""
|
|
149 |
||
150 |
upload_dir = 'upload/' |
|
151 |
branch_dir = 'branch/' |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
152 |
|
|
0.152.10
by Vincent Ladeuil
Fix incremental upload cheat. |
153 |
def make_local_branch(self): |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
154 |
t = transport.get_transport('branch') |
155 |
t.ensure_base() |
|
156 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
157 |
t.base, |
|
158 |
format=bzrdir.format_registry.make_bzrdir('default'), |
|
159 |
force_new_tree=False) |
|
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
160 |
self.tree = branch.bzrdir.create_workingtree() |
161 |
self.tree.commit('initial empty tree') |
|
162 |
||
163 |
def assertUpFileEqual(self, content, path, base=upload_dir): |
|
164 |
self.assertFileEqual(content, base + path) |
|
165 |
||
|
0.152.46
by Vincent Ladeuil
Handle x mode bit for files and provides default mode bits for |
166 |
def assertUpPathModeEqual(self, path, expected_mode, base=upload_dir): |
167 |
# FIXME: the tests needing that assertion should depend on the server
|
|
168 |
# ability to handle chmod so that they don't fail (or be skipped)
|
|
169 |
# against servers that can't. Note that some bzrlib transports define
|
|
170 |
# _can_roundtrip_unix_modebits in a incomplete way, this property
|
|
171 |
# should depend on both the client and the server, not the client only.
|
|
172 |
st = os.stat(base + path) |
|
173 |
mode = st.st_mode & 0777 |
|
174 |
if expected_mode == mode: |
|
175 |
return
|
|
176 |
raise AssertionError( |
|
177 |
'For path %s, mode is %s not %s' % |
|
178 |
(base + path, oct(mode), oct(expected_mode))) |
|
179 |
||
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
180 |
def failIfUpFileExists(self, path, base=upload_dir): |
181 |
self.failIfExists(base + path) |
|
182 |
||
183 |
def failUnlessUpFileExists(self, path, base=upload_dir): |
|
184 |
self.failUnlessExists(base + path) |
|
185 |
||
186 |
def set_file_content(self, name, content, base=branch_dir): |
|
187 |
f = file(base + name, 'wb') |
|
188 |
try: |
|
189 |
f.write(content) |
|
190 |
finally: |
|
191 |
f.close() |
|
192 |
||
193 |
def add_file(self, name, content, base=branch_dir): |
|
194 |
self.set_file_content(name, content, base) |
|
195 |
self.tree.add(name) |
|
196 |
self.tree.commit('add file %s' % name) |
|
197 |
||
198 |
def modify_file(self, name, content, base=branch_dir): |
|
199 |
self.set_file_content(name, content, base) |
|
200 |
self.tree.commit('modify file %s' % name) |
|
201 |
||
|
0.152.46
by Vincent Ladeuil
Handle x mode bit for files and provides default mode bits for |
202 |
def chmod_file(self, name, mode, base=branch_dir): |
203 |
path = base + name |
|
204 |
os.chmod(path, mode) |
|
205 |
self.tree.commit('change file %s mode to %s' % (name, oct(mode))) |
|
206 |
||
|
0.152.17
by Vincent Ladeuil
Handle deletes (trivial implementation). |
207 |
def delete_any(self, name, base=branch_dir): |
208 |
self.tree.remove([name], keep_files=False) |
|
209 |
self.tree.commit('delete %s' % name) |
|
210 |
||
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
211 |
def add_dir(self, name, base=branch_dir): |
212 |
os.mkdir(base + name) |
|
213 |
self.tree.add(name) |
|
214 |
self.tree.commit('add directory %s' % name) |
|
215 |
||
216 |
def rename_any(self, old_name, new_name): |
|
217 |
self.tree.rename_one(old_name, new_name) |
|
218 |
self.tree.commit('rename %s into %s' % (old_name, new_name)) |
|
|
0.152.13
by Vincent Ladeuil
Test uploading an empty tree. |
219 |
|
|
0.152.19
by Vincent Ladeuil
Handle kind_change. Trivial implementation, blocked by bug #205636. |
220 |
def transform_dir_into_file(self, name, content, base=branch_dir): |
221 |
osutils.delete_any(base + name) |
|
222 |
self.set_file_content(name, content, base) |
|
223 |
self.tree.commit('change %s from dir to file' % name) |
|
224 |
||
225 |
def transform_file_into_dir(self, name, base=branch_dir): |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
226 |
# bzr can't handle that kind change in a single commit without an
|
227 |
# intervening bzr status (see bug #205636).
|
|
228 |
self.tree.remove([name], keep_files=False) |
|
|
0.152.19
by Vincent Ladeuil
Handle kind_change. Trivial implementation, blocked by bug #205636. |
229 |
os.mkdir(base + name) |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
230 |
self.tree.add(name) |
|
0.152.19
by Vincent Ladeuil
Handle kind_change. Trivial implementation, blocked by bug #205636. |
231 |
self.tree.commit('change %s from file to dir' % name) |
232 |
||
|
0.152.32
by Vincent Ladeuil
Restore verbose as the default mode. |
233 |
def _get_cmd_upload(self): |
234 |
upload = cmd_upload() |
|
235 |
# We don't want to use run_bzr here because redirected output are a
|
|
236 |
# pain to debug. But we need to provides a valid outf.
|
|
237 |
# XXX: Should a bug against bzr be filled about that ?
|
|
238 |
upload._setup_outf() |
|
239 |
return upload |
|
240 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
241 |
def do_full_upload(self, *args, **kwargs): |
|
0.152.32
by Vincent Ladeuil
Restore verbose as the default mode. |
242 |
upload = self._get_cmd_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
243 |
up_url = self.get_transport(self.upload_dir).external_url() |
|
0.152.11
by Vincent Ladeuil
Be coherent with bzr push. |
244 |
if kwargs.get('directory', None) is None: |
245 |
kwargs['directory'] = 'branch' |
|
|
0.152.9
by Vincent Ladeuil
Recfactoring to simplify tests writing. |
246 |
kwargs['full'] = True |
|
0.152.34
by Martin Albisetti
* Change the default behaviour to be more verbose |
247 |
kwargs['quiet'] = True |
|
0.152.9
by Vincent Ladeuil
Recfactoring to simplify tests writing. |
248 |
upload.run(up_url, *args, **kwargs) |
249 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
250 |
def do_incremental_upload(self, *args, **kwargs): |
|
0.152.32
by Vincent Ladeuil
Restore verbose as the default mode. |
251 |
upload = self._get_cmd_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
252 |
up_url = self.get_transport(self.upload_dir).external_url() |
|
0.152.11
by Vincent Ladeuil
Be coherent with bzr push. |
253 |
if kwargs.get('directory', None) is None: |
254 |
kwargs['directory'] = 'branch' |
|
|
0.152.34
by Martin Albisetti
* Change the default behaviour to be more verbose |
255 |
kwargs['quiet'] = True |
|
0.152.9
by Vincent Ladeuil
Recfactoring to simplify tests writing. |
256 |
upload.run(up_url, *args, **kwargs) |
257 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
258 |
def test_create_file(self): |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
259 |
self.make_local_branch() |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
260 |
self.do_full_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
261 |
self.add_file('hello', 'foo') |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
262 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
263 |
self.do_upload() |
264 |
||
265 |
self.assertUpFileEqual('foo', 'hello') |
|
266 |
||
267 |
def test_create_file_in_subdir(self): |
|
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
268 |
self.make_local_branch() |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
269 |
self.do_full_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
270 |
self.add_dir('dir') |
271 |
self.add_file('dir/goodbye', 'baz') |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
272 |
|
273 |
self.failIfUpFileExists('dir/goodbye') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
274 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
275 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
276 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
277 |
self.assertUpFileEqual('baz', 'dir/goodbye') |
|
0.152.46
by Vincent Ladeuil
Handle x mode bit for files and provides default mode bits for |
278 |
self.assertUpPathModeEqual('dir', 0775) |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
279 |
|
280 |
def test_modify_file(self): |
|
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
281 |
self.make_local_branch() |
282 |
self.add_file('hello', 'foo') |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
283 |
self.do_full_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
284 |
self.modify_file('hello', 'bar') |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
285 |
|
286 |
self.assertUpFileEqual('foo', 'hello') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
287 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
288 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
289 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
290 |
self.assertUpFileEqual('bar', 'hello') |
291 |
||
|
0.152.16
by Vincent Ladeuil
Handle renames. Robust implementation. |
292 |
def test_rename_one_file(self): |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
293 |
self.make_local_branch() |
294 |
self.add_file('hello', 'foo') |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
295 |
self.do_full_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
296 |
self.rename_any('hello', 'goodbye') |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
297 |
|
298 |
self.assertUpFileEqual('foo', 'hello') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
299 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
300 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
301 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
302 |
self.assertUpFileEqual('foo', 'goodbye') |
303 |
||
|
0.152.52
by Vincent Ladeuil
Fix bug #270219 by handling content changes during renames. |
304 |
def test_rename_and_change_file(self): |
305 |
self.make_local_branch() |
|
306 |
self.add_file('hello', 'foo') |
|
307 |
self.do_full_upload() |
|
308 |
self.rename_any('hello', 'goodbye') |
|
309 |
self.modify_file('goodbye', 'bar') |
|
310 |
||
311 |
self.assertUpFileEqual('foo', 'hello') |
|
312 |
||
313 |
self.do_upload() |
|
314 |
||
315 |
self.assertUpFileEqual('bar', 'goodbye') |
|
316 |
||
|
0.152.16
by Vincent Ladeuil
Handle renames. Robust implementation. |
317 |
def test_rename_two_files(self): |
318 |
self.make_local_branch() |
|
319 |
self.add_file('a', 'foo') |
|
320 |
self.add_file('b', 'qux') |
|
321 |
self.do_full_upload() |
|
322 |
# We rely on the assumption that bzr will topologically sort the
|
|
323 |
# renames which will cause a -> b to appear *before* b -> c
|
|
324 |
self.rename_any('b', 'c') |
|
325 |
self.rename_any('a', 'b') |
|
326 |
||
327 |
self.assertUpFileEqual('foo', 'a') |
|
328 |
self.assertUpFileEqual('qux', 'b') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
329 |
|
|
0.152.16
by Vincent Ladeuil
Handle renames. Robust implementation. |
330 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
331 |
|
|
0.152.16
by Vincent Ladeuil
Handle renames. Robust implementation. |
332 |
self.assertUpFileEqual('foo', 'b') |
333 |
self.assertUpFileEqual('qux', 'c') |
|
334 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
335 |
def test_upload_revision(self): |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
336 |
self.make_local_branch() # rev1 |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
337 |
self.do_full_upload() |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
338 |
self.add_file('hello', 'foo') # rev2 |
339 |
self.modify_file('hello', 'bar') # rev3 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
340 |
|
341 |
self.failIfUpFileExists('hello') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
342 |
|
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
343 |
revspec = revisionspec.RevisionSpec.from_string('2') |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
344 |
self.do_upload(revision=[revspec]) |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
345 |
|
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
346 |
self.assertUpFileEqual('foo', 'hello') |
347 |
||
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
348 |
def test_no_upload_when_changes(self): |
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
349 |
self.make_local_branch() |
350 |
self.add_file('a', 'foo') |
|
351 |
self.set_file_content('a', 'bar') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
352 |
|
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
353 |
self.assertRaises(errors.UncommittedChanges, self.do_upload) |
354 |
||
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
355 |
def test_no_upload_when_conflicts(self): |
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
356 |
self.make_local_branch() |
357 |
self.add_file('a', 'foo') |
|
358 |
self.run_bzr('branch branch other') |
|
359 |
self.modify_file('a', 'bar') |
|
360 |
other_tree = workingtree.WorkingTree.open('other') |
|
361 |
self.set_file_content('a', 'baz', 'other/') |
|
362 |
other_tree.commit('modify file a') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
363 |
|
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
364 |
self.run_bzr('merge -d branch other', retcode=1) |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
365 |
|
|
0.152.33
by Vincent Ladeuil
Ensure that we refuse to upload if the working tree contains |
366 |
self.assertRaises(errors.UncommittedChanges, self.do_upload) |
367 |
||
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
368 |
def test_change_file_into_dir(self): |
369 |
self.make_local_branch() |
|
370 |
self.add_file('hello', 'foo') |
|
371 |
self.do_full_upload() |
|
372 |
self.transform_file_into_dir('hello') |
|
373 |
self.add_file('hello/file', 'bar') |
|
374 |
||
375 |
self.assertUpFileEqual('foo', 'hello') |
|
376 |
||
377 |
self.do_upload() |
|
378 |
||
379 |
self.assertUpFileEqual('bar', 'hello/file') |
|
380 |
||
381 |
def test_change_dir_into_file(self): |
|
382 |
self.make_local_branch() |
|
383 |
self.add_dir('hello') |
|
384 |
self.add_file('hello/file', 'foo') |
|
385 |
self.do_full_upload() |
|
386 |
self.delete_any('hello/file') |
|
387 |
self.transform_dir_into_file('hello', 'bar') |
|
388 |
||
389 |
self.assertUpFileEqual('foo', 'hello/file') |
|
390 |
||
391 |
self.do_upload() |
|
392 |
||
393 |
self.assertUpFileEqual('bar', 'hello') |
|
394 |
||
|
0.152.46
by Vincent Ladeuil
Handle x mode bit for files and provides default mode bits for |
395 |
def test_make_file_executable(self): |
396 |
self.make_local_branch() |
|
397 |
self.add_file('hello', 'foo') |
|
398 |
self.chmod_file('hello', 0664) |
|
399 |
self.do_full_upload() |
|
400 |
self.chmod_file('hello', 0755) |
|
401 |
||
402 |
self.assertUpPathModeEqual('hello', 0664) |
|
403 |
||
404 |
self.do_upload() |
|
405 |
||
406 |
self.assertUpPathModeEqual('hello', 0775) |
|
407 |
||
|
0.155.4
by James Westby
Add the groundwork for --auto that enables the hook for a branch. |
408 |
def test_upload_auto(self): |
409 |
"""Test that upload --auto sets the upload_auto option""" |
|
410 |
self.make_local_branch() |
|
411 |
self.add_file('hello', 'foo') |
|
412 |
self.assertFalse(get_upload_auto(self.tree.branch)) |
|
413 |
self.do_full_upload(auto=True) |
|
414 |
self.assertUpFileEqual('foo', 'hello') |
|
415 |
self.assertTrue(get_upload_auto(self.tree.branch)) |
|
416 |
# and check that it stays set until it is unset
|
|
417 |
self.add_file('bye', 'bar') |
|
418 |
self.do_full_upload() |
|
419 |
self.assertUpFileEqual('bar', 'bye') |
|
420 |
self.assertTrue(get_upload_auto(self.tree.branch)) |
|
421 |
||
422 |
def test_upload_noauto(self): |
|
423 |
"""Test that upload --no-auto unsets the upload_auto option""" |
|
424 |
self.make_local_branch() |
|
425 |
self.add_file('hello', 'foo') |
|
426 |
self.assertFalse(get_upload_auto(self.tree.branch)) |
|
427 |
self.do_full_upload(auto=True) |
|
428 |
self.assertUpFileEqual('foo', 'hello') |
|
429 |
self.assertTrue(get_upload_auto(self.tree.branch)) |
|
430 |
self.add_file('bye', 'bar') |
|
431 |
self.do_full_upload(auto=False) |
|
432 |
self.assertUpFileEqual('bar', 'bye') |
|
433 |
self.assertFalse(get_upload_auto(self.tree.branch)) |
|
434 |
# and check that it stays unset until it is set
|
|
435 |
self.add_file('again', 'baz') |
|
436 |
self.do_full_upload() |
|
437 |
self.assertUpFileEqual('baz', 'again') |
|
438 |
self.assertFalse(get_upload_auto(self.tree.branch)) |
|
439 |
||
|
0.156.1
by James Westby
Use open_containing rather than open, so that you can upload from a subdir. |
440 |
def test_upload_from_subdir(self): |
441 |
self.make_local_branch() |
|
442 |
self.build_tree(['branch/foo/', 'branch/foo/bar']) |
|
443 |
self.tree.add(['foo/', 'foo/bar']) |
|
444 |
self.tree.commit("Add directory") |
|
445 |
self.do_full_upload(directory='branch/foo') |
|
446 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
447 |
|
448 |
class TestFullUpload(tests.TestCaseWithTransport, TestUploadMixin): |
|
449 |
||
450 |
do_upload = TestUploadMixin.do_full_upload |
|
451 |
||
|
0.152.13
by Vincent Ladeuil
Test uploading an empty tree. |
452 |
def test_full_upload_empty_tree(self): |
453 |
self.make_local_branch() |
|
454 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
455 |
self.do_full_upload() |
|
0.152.13
by Vincent Ladeuil
Test uploading an empty tree. |
456 |
|
|
0.155.1
by James Westby
Switch most of the logic to a class outside of the command class. |
457 |
self.failUnlessUpFileExists(BzrUploader.bzr_upload_revid_file_name) |
|
0.152.13
by Vincent Ladeuil
Test uploading an empty tree. |
458 |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
459 |
def test_invalid_revspec(self): |
|
0.152.15
by Vincent Ladeuil
Simplify test writing (for good ?). |
460 |
self.make_local_branch() |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
461 |
rev1 = revisionspec.RevisionSpec.from_string('1') |
462 |
rev2 = revisionspec.RevisionSpec.from_string('2') |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
463 |
|
|
0.152.9
by Vincent Ladeuil
Recfactoring to simplify tests writing. |
464 |
self.assertRaises(errors.BzrCommandError, |
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
465 |
self.do_incremental_upload, revision=[rev1, rev2]) |
466 |
||
|
0.152.47
by Vincent Ladeuil
Don't fail a full upload on an already existing dir. |
467 |
def test_create_remote_dir_twice(self): |
468 |
self.make_local_branch() |
|
469 |
self.add_dir('dir') |
|
470 |
self.do_full_upload() |
|
471 |
self.add_file('dir/goodbye', 'baz') |
|
472 |
||
473 |
self.failIfUpFileExists('dir/goodbye') |
|
474 |
||
475 |
self.do_full_upload() |
|
476 |
||
477 |
self.assertUpFileEqual('baz', 'dir/goodbye') |
|
478 |
self.assertUpPathModeEqual('dir', 0775) |
|
479 |
||
|
0.152.14
by Vincent Ladeuil
Handle renames (trivial implementation). |
480 |
|
481 |
class TestIncrementalUpload(tests.TestCaseWithTransport, TestUploadMixin): |
|
482 |
||
483 |
do_upload = TestUploadMixin.do_incremental_upload |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
484 |
|
|
0.152.19
by Vincent Ladeuil
Handle kind_change. Trivial implementation, blocked by bug #205636. |
485 |
# XXX: full upload doesn't handle deletions....
|
|
0.152.17
by Vincent Ladeuil
Handle deletes (trivial implementation). |
486 |
|
487 |
def test_delete_one_file(self): |
|
488 |
self.make_local_branch() |
|
489 |
self.add_file('hello', 'foo') |
|
490 |
self.do_full_upload() |
|
491 |
self.delete_any('hello') |
|
492 |
||
493 |
self.assertUpFileEqual('foo', 'hello') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
494 |
|
|
0.152.17
by Vincent Ladeuil
Handle deletes (trivial implementation). |
495 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
496 |
|
|
0.152.17
by Vincent Ladeuil
Handle deletes (trivial implementation). |
497 |
self.failIfUpFileExists('hello') |
498 |
||
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
499 |
def test_delete_dir_and_subdir(self): |
500 |
self.make_local_branch() |
|
501 |
self.add_dir('dir') |
|
502 |
self.add_dir('dir/subdir') |
|
503 |
self.add_file('dir/subdir/a', 'foo') |
|
504 |
self.do_full_upload() |
|
505 |
self.rename_any('dir/subdir/a', 'a') |
|
506 |
self.delete_any('dir/subdir') |
|
507 |
self.delete_any('dir') |
|
508 |
||
509 |
self.assertUpFileEqual('foo', 'dir/subdir/a') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
510 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
511 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
512 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
513 |
self.failIfUpFileExists('dir/subdir/a') |
514 |
self.failIfUpFileExists('dir/subdir') |
|
515 |
self.failIfUpFileExists('dir') |
|
516 |
self.assertUpFileEqual('foo', 'a') |
|
517 |
||
518 |
def test_delete_one_file_rename_to_deleted(self): |
|
519 |
self.make_local_branch() |
|
520 |
self.add_file('a', 'foo') |
|
521 |
self.add_file('b', 'bar') |
|
522 |
self.do_full_upload() |
|
523 |
self.delete_any('a') |
|
524 |
self.rename_any('b', 'a') |
|
525 |
||
526 |
self.assertUpFileEqual('foo', 'a') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
527 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
528 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
529 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
530 |
self.failIfUpFileExists('b') |
531 |
self.assertUpFileEqual('bar', 'a') |
|
532 |
||
533 |
def test_rename_outside_dir_delete_dir(self): |
|
534 |
self.make_local_branch() |
|
535 |
self.add_dir('dir') |
|
536 |
self.add_file('dir/a', 'foo') |
|
537 |
self.do_full_upload() |
|
538 |
self.rename_any('dir/a', 'a') |
|
539 |
self.delete_any('dir') |
|
540 |
||
541 |
self.assertUpFileEqual('foo', 'dir/a') |
|
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
542 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
543 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
544 |
|
|
0.152.18
by Vincent Ladeuil
Handle deletions. Robust implementation. |
545 |
self.failIfUpFileExists('dir/a') |
546 |
self.failIfUpFileExists('dir') |
|
547 |
self.assertUpFileEqual('foo', 'a') |
|
548 |
||
|
0.152.31
by Vincent Ladeuil
Cosmetic change. |
549 |
def test_upload_for_the_first_time_do_a_full_upload(self): |
|
0.152.25
by Martin Albisetti
Added test for uploading for the first time to a remote location |
550 |
self.make_local_branch() |
551 |
self.add_file('hello', 'bar') |
|
|
0.152.31
by Vincent Ladeuil
Cosmetic change. |
552 |
|
|
0.155.1
by James Westby
Switch most of the logic to a class outside of the command class. |
553 |
self.failIfUpFileExists(BzrUploader.bzr_upload_revid_file_name) |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
554 |
|
|
0.152.25
by Martin Albisetti
Added test for uploading for the first time to a remote location |
555 |
self.do_upload() |
|
0.152.44
by Vincent Ladeuil
More robust full upload (at least regarding files changed to dirs and vice-versa). |
556 |
|
|
0.152.25
by Martin Albisetti
Added test for uploading for the first time to a remote location |
557 |
self.assertUpFileEqual('bar', 'hello') |
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
558 |
|
|
0.153.1
by Vincent Ladeuil
Clean up references to verbose. |
559 |
|
|
0.152.12
by Vincent Ladeuil
Implement 'upload_location' in config files. |
560 |
class TestBranchUploadLocations(branch_implementations.TestCaseWithBranch): |
561 |
||
562 |
def test_get_upload_location_unset(self): |
|
563 |
config = self.get_branch().get_config() |
|
564 |
self.assertEqual(None, config.get_user_option('upload_location')) |
|
565 |
||
566 |
def test_get_push_location_exact(self): |
|
567 |
from bzrlib.config import (locations_config_filename, |
|
568 |
ensure_config_dir_exists) |
|
569 |
ensure_config_dir_exists() |
|
570 |
fn = locations_config_filename() |
|
571 |
b = self.get_branch() |
|
572 |
open(fn, 'wt').write(("[%s]\n" |
|
573 |
"upload_location=foo\n" % |
|
574 |
b.base[:-1])) |
|
575 |
config = b.get_config() |
|
576 |
self.assertEqual("foo", config.get_user_option('upload_location')) |
|
577 |
||
578 |
def test_set_push_location(self): |
|
579 |
config = self.get_branch().get_config() |
|
580 |
config.set_user_option('upload_location', 'foo') |
|
581 |
self.assertEqual('foo', config.get_user_option('upload_location')) |
|
582 |