bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
1 |
# Copyright (C) 2005, 2006 Canonical
|
|
1540.3.24
by Martin Pool
Add new protocol 'http+pycurl' that always uses PyCurl. |
2 |
#
|
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
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.
|
|
|
1540.3.24
by Martin Pool
Add new protocol 'http+pycurl' that always uses PyCurl. |
7 |
#
|
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
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.
|
|
|
1540.3.24
by Martin Pool
Add new protocol 'http+pycurl' that always uses PyCurl. |
12 |
#
|
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
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
|
|
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
16 |
|
|
1540.3.3
by Martin Pool
Review updates of pycurl transport |
17 |
# FIXME: This test should be repeated for each available http client
|
18 |
# implementation; at the moment we have urllib and pycurl.
|
|
19 |
||
|
1540.3.22
by Martin Pool
[patch] Add TestCase.assertIsInstance |
20 |
# TODO: Should be renamed to bzrlib.transport.http.tests?
|
21 |
||
|
2000.2.2
by John Arbash Meinel
Update the urllib.has test. |
22 |
import socket |
23 |
||
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
24 |
import bzrlib |
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
25 |
from bzrlib.errors import ( |
26 |
DependencyNotPresent, |
|
27 |
ConnectionError, |
|
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
28 |
InvalidHttpResponse, |
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
29 |
)
|
30 |
from bzrlib.tests import ( |
|
31 |
TestCase, |
|
32 |
TestSkipped, |
|
33 |
)
|
|
34 |
from bzrlib.transport import ( |
|
35 |
get_transport, |
|
36 |
Transport, |
|
37 |
)
|
|
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
38 |
from bzrlib.transport.http import ( |
39 |
extract_auth, |
|
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
40 |
BadProtocolRequestHandler, |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
41 |
BadStatusRequestHandler, |
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
42 |
HttpTransportBase, |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
43 |
InvalidStatusRequestHandler, |
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
44 |
WallRequestHandler, |
45 |
)
|
|
|
1540.3.26
by Martin Pool
[merge] bzr.dev; pycurl not updated for readv yet |
46 |
from bzrlib.transport.http._urllib import HttpTransport_urllib |
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
47 |
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver |
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
48 |
|
|
1786.1.8
by John Arbash Meinel
[merge] Johan Rydberg test updates |
49 |
|
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
50 |
class FakeManager (object): |
|
1786.1.8
by John Arbash Meinel
[merge] Johan Rydberg test updates |
51 |
|
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
52 |
def __init__(self): |
53 |
self.credentials = [] |
|
|
2004.3.1
by vila
Test ConnectionError exceptions. |
54 |
|
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
55 |
def add_password(self, realm, host, username, password): |
56 |
self.credentials.append([realm, host, username, password]) |
|
57 |
||
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
58 |
|
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
59 |
class TestHttpUrls(TestCase): |
|
1786.1.8
by John Arbash Meinel
[merge] Johan Rydberg test updates |
60 |
|
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
61 |
def test_url_parsing(self): |
62 |
f = FakeManager() |
|
63 |
url = extract_auth('http://example.com', f) |
|
64 |
self.assertEquals('http://example.com', url) |
|
65 |
self.assertEquals(0, len(f.credentials)) |
|
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
66 |
url = extract_auth('http://user:pass@www.bazaar-vcs.org/bzr/bzr.dev', f) |
67 |
self.assertEquals('http://www.bazaar-vcs.org/bzr/bzr.dev', url) |
|
|
1185.40.20
by Robey Pointer
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files |
68 |
self.assertEquals(1, len(f.credentials)) |
|
2004.3.1
by vila
Test ConnectionError exceptions. |
69 |
self.assertEquals([None, 'www.bazaar-vcs.org', 'user', 'pass'], |
70 |
f.credentials[0]) |
|
71 |
||
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
72 |
def test_abs_url(self): |
73 |
"""Construction of absolute http URLs""" |
|
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
74 |
t = HttpTransport_urllib('http://bazaar-vcs.org/bzr/bzr.dev/') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
75 |
eq = self.assertEqualDiff |
76 |
eq(t.abspath('.'), |
|
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
77 |
'http://bazaar-vcs.org/bzr/bzr.dev') |
|
2004.3.1
by vila
Test ConnectionError exceptions. |
78 |
eq(t.abspath('foo/bar'), |
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
79 |
'http://bazaar-vcs.org/bzr/bzr.dev/foo/bar') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
80 |
eq(t.abspath('.bzr'), |
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
81 |
'http://bazaar-vcs.org/bzr/bzr.dev/.bzr') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
82 |
eq(t.abspath('.bzr/1//2/./3'), |
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
83 |
'http://bazaar-vcs.org/bzr/bzr.dev/.bzr/1/2/3') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
84 |
|
85 |
def test_invalid_http_urls(self): |
|
86 |
"""Trap invalid construction of urls""" |
|
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
87 |
t = HttpTransport_urllib('http://bazaar-vcs.org/bzr/bzr.dev/') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
88 |
self.assertRaises(ValueError, |
89 |
t.abspath, |
|
90 |
'.bzr/') |
|
91 |
||
92 |
def test_http_root_urls(self): |
|
93 |
"""Construction of URLs from server root""" |
|
|
1540.3.26
by Martin Pool
[merge] bzr.dev; pycurl not updated for readv yet |
94 |
t = HttpTransport_urllib('http://bzr.ozlabs.org/') |
|
1185.16.68
by Martin Pool
- http url fixes suggested by Robey Pointer, and tests |
95 |
eq = self.assertEqualDiff |
96 |
eq(t.abspath('.bzr/tree-version'), |
|
97 |
'http://bzr.ozlabs.org/.bzr/tree-version') |
|
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
98 |
|
|
1540.3.24
by Martin Pool
Add new protocol 'http+pycurl' that always uses PyCurl. |
99 |
def test_http_impl_urls(self): |
100 |
"""There are servers which ask for particular clients to connect""" |
|
101 |
try: |
|
102 |
from bzrlib.transport.http._pycurl import HttpServer_PyCurl |
|
103 |
server = HttpServer_PyCurl() |
|
104 |
try: |
|
105 |
server.setUp() |
|
106 |
url = server.get_url() |
|
107 |
self.assertTrue(url.startswith('http+pycurl://')) |
|
108 |
finally: |
|
109 |
server.tearDown() |
|
|
1540.3.30
by Martin Pool
Fix up bogus-url tests for broken dns servers, and error imports |
110 |
except DependencyNotPresent: |
|
1540.3.24
by Martin Pool
Add new protocol 'http+pycurl' that always uses PyCurl. |
111 |
raise TestSkipped('pycurl not present') |
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
112 |
|
|
1786.1.8
by John Arbash Meinel
[merge] Johan Rydberg test updates |
113 |
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
114 |
class TestHttpConnections(object): |
115 |
"""Test the http connections. |
|
116 |
||
117 |
This MUST be used by daughter classes that also inherit from
|
|
118 |
TestCaseWithWebserver.
|
|
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
119 |
|
120 |
We can't inherit directly from TestCaseWithWebserver or the
|
|
121 |
test framework will try to create an instance which cannot
|
|
122 |
run, its implementation being incomplete.
|
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
123 |
"""
|
124 |
||
125 |
def setUp(self): |
|
126 |
TestCaseWithWebserver.setUp(self) |
|
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
127 |
self.build_tree(['xxx', 'foo/', 'foo/bar'], line_endings='binary', |
128 |
transport=self.get_transport()) |
|
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
129 |
|
130 |
def test_http_has(self): |
|
|
1185.50.84
by John Arbash Meinel
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout. |
131 |
server = self.get_readonly_server() |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
132 |
t = self._transport(server.get_url()) |
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
133 |
self.assertEqual(t.has('foo/bar'), True) |
|
1185.50.84
by John Arbash Meinel
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout. |
134 |
self.assertEqual(len(server.logs), 1) |
|
2004.3.1
by vila
Test ConnectionError exceptions. |
135 |
self.assertContainsRe(server.logs[0], |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
136 |
r'"HEAD /foo/bar HTTP/1.." (200|302) - "-" "bzr/') |
|
1553.1.5
by James Henstridge
Make HTTP transport has() method do HEAD requests, and update test to |
137 |
|
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
138 |
def test_http_has_not_found(self): |
139 |
server = self.get_readonly_server() |
|
140 |
t = self._transport(server.get_url()) |
|
|
1553.1.5
by James Henstridge
Make HTTP transport has() method do HEAD requests, and update test to |
141 |
self.assertEqual(t.has('not-found'), False) |
|
2004.3.1
by vila
Test ConnectionError exceptions. |
142 |
self.assertContainsRe(server.logs[1], |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
143 |
r'"HEAD /not-found HTTP/1.." 404 - "-" "bzr/') |
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
144 |
|
145 |
def test_http_get(self): |
|
|
1185.50.84
by John Arbash Meinel
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout. |
146 |
server = self.get_readonly_server() |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
147 |
t = self._transport(server.get_url()) |
|
1553.1.2
by James Henstridge
Add a test to make sure the user-agent header is being sent correctly. |
148 |
fp = t.get('foo/bar') |
149 |
self.assertEqualDiff( |
|
150 |
fp.read(), |
|
|
1553.1.3
by James Henstridge
Make bzrlib.transport.http.HttpServer output referer and user agent as in |
151 |
'contents of foo/bar\n') |
|
1185.50.84
by John Arbash Meinel
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout. |
152 |
self.assertEqual(len(server.logs), 1) |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
153 |
self.assertTrue(server.logs[0].find( |
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
154 |
'"GET /foo/bar HTTP/1.1" 200 - "-" "bzr/%s' |
155 |
% bzrlib.__version__) > -1) |
|
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
156 |
|
|
2000.2.2
by John Arbash Meinel
Update the urllib.has test. |
157 |
def test_has_on_bogus_host(self): |
|
2004.1.1
by vila
Connection sharing, with redirection. without authentification. |
158 |
# Get a free address and don't 'accept' on it, so that we
|
159 |
# can be sure there is no http handler there, but set a
|
|
160 |
# reasonable timeout to not slow down tests too much.
|
|
161 |
default_timeout = socket.getdefaulttimeout() |
|
162 |
try: |
|
163 |
socket.setdefaulttimeout(2) |
|
164 |
s = socket.socket() |
|
165 |
s.bind(('localhost', 0)) |
|
166 |
t = self._transport('http://%s:%s/' % s.getsockname()) |
|
167 |
self.assertRaises(ConnectionError, t.has, 'foo/bar') |
|
168 |
finally: |
|
169 |
socket.setdefaulttimeout(default_timeout) |
|
170 |
||
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
171 |
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
172 |
class TestWithTransport_pycurl(object): |
173 |
"""Test case to inherit from if pycurl is present""" |
|
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
174 |
def _get_pycurl_maybe(self): |
|
1540.3.29
by Martin Pool
Prevent selftest failure when pycurl is not installed |
175 |
try: |
176 |
from bzrlib.transport.http._pycurl import PyCurlTransport |
|
|
1612.1.1
by Martin Pool
Raise errors correctly on pycurl connection failure |
177 |
return PyCurlTransport |
|
1540.3.30
by Martin Pool
Fix up bogus-url tests for broken dns servers, and error imports |
178 |
except DependencyNotPresent: |
|
1540.3.29
by Martin Pool
Prevent selftest failure when pycurl is not installed |
179 |
raise TestSkipped('pycurl not present') |
|
1540.3.15
by Martin Pool
[merge] large merge to sync with bzr.dev |
180 |
|
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
181 |
_transport = property(_get_pycurl_maybe) |
182 |
||
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
183 |
|
184 |
class TestHttpConnections_urllib(TestHttpConnections, TestCaseWithWebserver): |
|
185 |
"""Test http connections with urllib""" |
|
186 |
||
187 |
_transport = HttpTransport_urllib |
|
188 |
||
189 |
||
190 |
||
191 |
class TestHttpConnections_pycurl(TestWithTransport_pycurl, |
|
192 |
TestHttpConnections, |
|
193 |
TestCaseWithWebserver): |
|
194 |
"""Test http connections with pycurl""" |
|
|
1540.3.33
by Martin Pool
Fix http tests that were failing to run tearDown when setup got a missing dependency |
195 |
|
196 |
||
|
1540.3.23
by Martin Pool
Allow urls like http+pycurl://host/ to use a particular impl |
197 |
class TestHttpTransportRegistration(TestCase): |
198 |
"""Test registrations of various http implementations""" |
|
199 |
||
200 |
def test_http_registered(self): |
|
201 |
# urlllib should always be present
|
|
202 |
t = get_transport('http+urllib://bzr.google.com/') |
|
203 |
self.assertIsInstance(t, Transport) |
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
204 |
self.assertIsInstance(t, HttpTransport_urllib) |
|
1786.1.23
by John Arbash Meinel
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests. |
205 |
|
206 |
||
207 |
class TestOffsets(TestCase): |
|
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
208 |
"""Test offsets_to_ranges method""" |
|
1786.1.23
by John Arbash Meinel
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests. |
209 |
|
210 |
def test_offsets_to_ranges_simple(self): |
|
211 |
to_range = HttpTransportBase.offsets_to_ranges |
|
|
1786.1.39
by John Arbash Meinel
Remove the ability to read negative offsets from readv() |
212 |
ranges = to_range([(10, 1)]) |
|
1786.1.23
by John Arbash Meinel
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests. |
213 |
self.assertEqual([[10, 10]], ranges) |
|
1786.1.39
by John Arbash Meinel
Remove the ability to read negative offsets from readv() |
214 |
|
215 |
ranges = to_range([(0, 1), (1, 1)]) |
|
216 |
self.assertEqual([[0, 1]], ranges) |
|
217 |
||
218 |
ranges = to_range([(1, 1), (0, 1)]) |
|
219 |
self.assertEqual([[0, 1]], ranges) |
|
|
1786.1.23
by John Arbash Meinel
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests. |
220 |
|
221 |
def test_offset_to_ranges_overlapped(self): |
|
222 |
to_range = HttpTransportBase.offsets_to_ranges |
|
223 |
||
|
1786.1.39
by John Arbash Meinel
Remove the ability to read negative offsets from readv() |
224 |
ranges = to_range([(10, 1), (20, 2), (22, 5)]) |
225 |
self.assertEqual([[10, 10], [20, 26]], ranges) |
|
226 |
||
227 |
ranges = to_range([(10, 1), (11, 2), (22, 5)]) |
|
228 |
self.assertEqual([[10, 12], [22, 26]], ranges) |
|
|
1786.1.23
by John Arbash Meinel
Move offset_to_http_ranges back onto HttpTransportBase, clarify tests. |
229 |
|
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
230 |
|
231 |
class TestRangeHeader(TestCase): |
|
232 |
"""Test range_header method""" |
|
233 |
||
234 |
def check_header(self, value, ranges=[], tail=0): |
|
235 |
range_header = HttpTransportBase.range_header |
|
236 |
self.assertEqual(value, range_header(ranges, tail)) |
|
237 |
||
238 |
def test_range_header_single(self): |
|
|
1786.1.36
by John Arbash Meinel
pycurl expects us to just set the range of bytes, not including bytes= |
239 |
self.check_header('0-9', ranges=[[0,9]]) |
240 |
self.check_header('100-109', ranges=[[100,109]]) |
|
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
241 |
|
242 |
def test_range_header_tail(self): |
|
|
1786.1.36
by John Arbash Meinel
pycurl expects us to just set the range of bytes, not including bytes= |
243 |
self.check_header('-10', tail=10) |
244 |
self.check_header('-50', tail=50) |
|
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
245 |
|
246 |
def test_range_header_multi(self): |
|
|
1786.1.36
by John Arbash Meinel
pycurl expects us to just set the range of bytes, not including bytes= |
247 |
self.check_header('0-9,100-200,300-5000', |
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
248 |
ranges=[(0,9), (100, 200), (300,5000)]) |
249 |
||
250 |
def test_range_header_mixed(self): |
|
|
1786.1.36
by John Arbash Meinel
pycurl expects us to just set the range of bytes, not including bytes= |
251 |
self.check_header('0-9,300-5000,-50', |
|
1786.1.28
by John Arbash Meinel
Update and add tests for the HttpTransportBase.range_header |
252 |
ranges=[(0,9), (300,5000)], |
253 |
tail=50) |
|
|
2004.3.1
by vila
Test ConnectionError exceptions. |
254 |
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
255 |
|
256 |
class TestWallServer(object): |
|
257 |
"""Tests exceptions during the connection phase""" |
|
258 |
||
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
259 |
def create_transport_readonly_server(self): |
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
260 |
return bzrlib.transport.http.HttpServer(WallRequestHandler) |
261 |
||
262 |
def test_http_has(self): |
|
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
263 |
server = self.get_readonly_server() |
|
2004.3.1
by vila
Test ConnectionError exceptions. |
264 |
t = self._transport(server.get_url()) |
265 |
self.assertRaises(ConnectionError, t.has, 'foo/bar') |
|
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
266 |
|
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
267 |
def test_http_get(self): |
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
268 |
server = self.get_readonly_server() |
|
2004.3.3
by vila
Better (but still incomplete) design for bogus servers. |
269 |
t = self._transport(server.get_url()) |
270 |
self.assertRaises(ConnectionError, t.get, 'foo/bar') |
|
271 |
||
272 |
||
|
2004.1.15
by v.ladeuil+lp at free
Better design for bogus servers. Both urllib and pycurl pass tests. |
273 |
class TestWallServer_urllib(TestWallServer, TestCaseWithWebserver): |
274 |
"""Tests WallServer for urllib implementation""" |
|
275 |
||
276 |
_transport = HttpTransport_urllib |
|
277 |
||
278 |
||
279 |
class TestWallServer_pycurl(TestWithTransport_pycurl, |
|
280 |
TestWallServer, |
|
281 |
TestCaseWithWebserver): |
|
282 |
"""Tests WallServer for pycurl implementation""" |
|
283 |
||
284 |
||
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
285 |
class TestBadStatusServer(object): |
286 |
"""Tests bad status from server.""" |
|
287 |
||
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
288 |
def create_transport_readonly_server(self): |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
289 |
return bzrlib.transport.http.HttpServer(BadStatusRequestHandler) |
290 |
||
291 |
def test_http_has(self): |
|
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
292 |
server = self.get_readonly_server() |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
293 |
t = self._transport(server.get_url()) |
294 |
self.assertRaises(InvalidHttpResponse, t.has, 'foo/bar') |
|
295 |
||
296 |
def test_http_get(self): |
|
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
297 |
server = self.get_readonly_server() |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
298 |
t = self._transport(server.get_url()) |
299 |
self.assertRaises(InvalidHttpResponse, t.get, 'foo/bar') |
|
300 |
||
301 |
||
302 |
class TestBadStatusServer_urllib(TestBadStatusServer, TestCaseWithWebserver): |
|
303 |
"""Tests BadStatusServer for urllib implementation""" |
|
304 |
||
305 |
_transport = HttpTransport_urllib |
|
306 |
||
307 |
||
308 |
class TestBadStatusServer_pycurl(TestWithTransport_pycurl, |
|
309 |
TestBadStatusServer, |
|
310 |
TestCaseWithWebserver): |
|
311 |
"""Tests BadStatusServer for pycurl implementation""" |
|
312 |
||
313 |
||
314 |
class TestInvalidStatusServer(TestBadStatusServer): |
|
315 |
"""Tests invalid status from server. |
|
316 |
||
317 |
Both implementations raises the same error as for a bad status.
|
|
318 |
"""
|
|
319 |
||
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
320 |
def create_transport_readonly_server(self): |
|
2004.1.16
by v.ladeuil+lp at free
Add tests against erroneous http status lines. |
321 |
return bzrlib.transport.http.HttpServer(InvalidStatusRequestHandler) |
322 |
||
323 |
||
324 |
class TestInvalidStatusServer_urllib(TestInvalidStatusServer, |
|
325 |
TestCaseWithWebserver): |
|
326 |
"""Tests InvalidStatusServer for urllib implementation""" |
|
327 |
||
328 |
_transport = HttpTransport_urllib |
|
329 |
||
330 |
||
331 |
class TestInvalidStatusServer_pycurl(TestWithTransport_pycurl, |
|
332 |
TestInvalidStatusServer, |
|
333 |
TestCaseWithWebserver): |
|
334 |
"""Tests InvalidStatusServer for pycurl implementation""" |
|
|
2004.1.19
by v.ladeuil+lp at free
Test protocol version in http responses. |
335 |
|
336 |
||
337 |
class TestBadProtocolServer(object): |
|
338 |
"""Tests bad status from server.""" |
|
339 |
||
340 |
def create_transport_readonly_server(self): |
|
341 |
return bzrlib.transport.http.HttpServer(BadProtocolRequestHandler) |
|
342 |
||
343 |
def test_http_has(self): |
|
344 |
server = self.get_readonly_server() |
|
345 |
t = self._transport(server.get_url()) |
|
346 |
self.assertRaises(InvalidHttpResponse, t.has, 'foo/bar') |
|
347 |
||
348 |
def test_http_get(self): |
|
349 |
server = self.get_readonly_server() |
|
350 |
t = self._transport(server.get_url()) |
|
351 |
self.assertRaises(InvalidHttpResponse, t.get, 'foo/bar') |
|
352 |
||
353 |
||
354 |
class TestBadProtocolServer_urllib(TestBadProtocolServer, |
|
355 |
TestCaseWithWebserver): |
|
356 |
"""Tests BadProtocolServer for urllib implementation""" |
|
357 |
||
358 |
_transport = HttpTransport_urllib |
|
359 |
||
360 |
# curl don't check the protocol version
|
|
361 |
#class TestBadProtocolServer_pycurl(TestWithTransport_pycurl,
|
|
362 |
# TestBadProtocolServer,
|
|
363 |
# TestCaseWithWebserver):
|
|
364 |
# """Tests BadProtocolServer for pycurl implementation"""
|
|
365 |
||
366 |