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 |
18 |
||
19 |
||
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
20 |
from bzrlib import ( |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
21 |
bzrdir, |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
22 |
errors, |
23 |
revisionspec, |
|
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
24 |
tests, |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
25 |
transport, |
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
26 |
)
|
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
27 |
from bzrlib.tests import test_transport_implementations |
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
28 |
|
29 |
from bzrlib.plugins.upload import cmd_upload |
|
|
0.152.1
by Vincent Ladeuil
Empty shell |
30 |
|
31 |
||
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
32 |
class TransportAdapter( |
33 |
test_transport_implementations.TransportTestProviderAdapter): |
|
34 |
"""A tool to generate a suite testing all transports for a single test. |
|
35 |
||
36 |
We restrict the transports to the ones we want to support.
|
|
37 |
"""
|
|
38 |
||
39 |
def _test_permutations(self): |
|
40 |
"""Return a list of the klass, server_factory pairs to test.""" |
|
41 |
result = [] |
|
42 |
transport_modules =['bzrlib.transport.ftp', |
|
43 |
'bzrlib.transport.sftp'] |
|
44 |
for module in transport_modules: |
|
45 |
try: |
|
46 |
permutations = self.get_transport_test_permutations( |
|
47 |
reduce(getattr, (module).split('.')[1:], |
|
48 |
__import__(module))) |
|
49 |
for (klass, server_factory) in permutations: |
|
50 |
scenario = (server_factory.__name__, |
|
51 |
{"transport_class":klass, |
|
52 |
"transport_server":server_factory}) |
|
53 |
result.append(scenario) |
|
54 |
except errors.DependencyNotPresent, e: |
|
55 |
# Continue even if a dependency prevents us
|
|
56 |
# from adding this test
|
|
57 |
pass
|
|
58 |
return result |
|
59 |
||
60 |
||
61 |
def load_tests(standard_tests, module, loader): |
|
62 |
"""Multiply tests for tranport implementations.""" |
|
63 |
result = loader.suiteClass() |
|
64 |
adapter = TransportAdapter() |
|
65 |
for test in tests.iter_suite_tests(standard_tests): |
|
66 |
result.addTests(adapter.adapt(test)) |
|
67 |
return result |
|
68 |
||
69 |
||
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
70 |
class TestUpload(tests.TestCaseWithTransport): |
71 |
||
72 |
def _create_branch(self): |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
73 |
# We need a local branch not a remote one
|
74 |
t = transport.get_transport('branch') |
|
75 |
t.ensure_base() |
|
76 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
77 |
t.base, |
|
78 |
format=bzrdir.format_registry.make_bzrdir('default'), |
|
79 |
force_new_tree=False) |
|
80 |
tree = branch.bzrdir.create_workingtree() |
|
81 |
return tree |
|
82 |
||
83 |
def _add_hello(self, tree): |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
84 |
self.build_tree_contents([('branch/hello', 'foo')]) |
85 |
tree.add('hello') |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
86 |
tree.commit('add hello') |
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
87 |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
88 |
def _modify_hello_add_goodbye(self, tree): |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
89 |
self.build_tree_contents([('branch/hello', 'bar'), |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
90 |
('branch/dir/',), |
91 |
('branch/dir/goodbye', 'baz')]) |
|
92 |
tree.add('dir') |
|
93 |
tree.add('dir/goodbye') |
|
94 |
tree.commit('modify hello, add goodbye') |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
95 |
|
96 |
def test_full_upload(self): |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
97 |
tree = self._create_branch() |
98 |
self._add_hello(tree) |
|
99 |
self._modify_hello_add_goodbye(tree) |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
100 |
|
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
101 |
upload = cmd_upload() |
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
102 |
up_url = self.get_transport('upload').external_url() |
|
0.152.4
by v.ladeuil+lp at free
Implement a trivial implementation to make one test pass. |
103 |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
104 |
upload.run(up_url, full=True, working_dir='branch') |
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
105 |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
106 |
self.assertFileEqual('bar', 'upload/hello') |
107 |
self.assertFileEqual('baz', 'upload/dir/goodbye') |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
108 |
|
109 |
def test_incremental_upload(self): |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
110 |
tree = self._create_branch() |
111 |
self._add_hello(tree) |
|
112 |
self._modify_hello_add_goodbye(tree) |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
113 |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
114 |
upload = cmd_upload() |
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
115 |
up_url = self.get_transport('upload').external_url() |
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
116 |
|
117 |
# Upload revision 1 only
|
|
118 |
revspec = revisionspec.RevisionSpec.from_string('1') |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
119 |
upload.run(up_url, revision=[revspec], full=True, working_dir='branch') |
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
120 |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
121 |
self.assertFileEqual('foo', 'upload/hello') |
122 |
self.failIfExists('upload/dir/goodbye') |
|
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
123 |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
124 |
# Upload current revision
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
125 |
upload.run(up_url, working_dir='branch') |
|
0.152.2
by v.ladeuil+lp at free
Add failing tests for basic usage. |
126 |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
127 |
self.assertFileEqual('bar', 'upload/hello') |
128 |
self.assertFileEqual('baz', 'upload/dir/goodbye') |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
129 |
|
130 |
def test_invalid_revspec(self): |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
131 |
tree = self._create_branch() |
132 |
self._add_hello(tree) |
|
133 |
self._modify_hello_add_goodbye(tree) |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
134 |
rev1 = revisionspec.RevisionSpec.from_string('1') |
135 |
rev2 = revisionspec.RevisionSpec.from_string('2') |
|
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
136 |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
137 |
upload = cmd_upload() |
|
0.152.6
by Vincent Ladeuil
Really use the transports and test against all targeted protocols. |
138 |
up_url = self.get_transport('upload').external_url() |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
139 |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
140 |
self.assertRaises(errors.BzrCommandError, upload.run, |
|
0.152.8
by Vincent Ladeuil
Handle uploading directories. |
141 |
up_url, revision=[rev1, rev2], |
142 |
working_dir='branch') |
|
|
0.152.5
by v.ladeuil+lp at free
Partial incremental upload implementationm tests pass. |
143 |