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