/brz/remove-bazaar

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