~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_pycurl.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-12 14:29:32 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061012142932-7221fe16d2b48fa3
Shuffle http related test code. Hopefully it ends up at the right place :)

* bzrlib/tests/HttpServer.py: 
New file. bzrlib.tests.ChrootedTestCase use HttpServer. So the
class can't be defined in bzrlib.tests.HTTPUtils because it
creates a circular dependency (bzrlib.tests.HTTPUtils needs to
import bzrlib.tests).

* bzrlib/transport/http/_urllib.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/_pycurl.py: 
Transfer test server definition to bzrlib.tests.HttpServer. Clean
up imports.

* bzrlib/transport/http/__init__.py: 
Transfer all test related code to either bzrlib.tests.HttpServer
and bzrlib.tests.HTTPUtils.
Fix all use of TransportNotPossible and InvalidURL by prefixing it
by 'errors.' (this seems to be the preferred way in the rest of
bzr).
Get rid of unused imports.

* bzrlib/tests/test_transport.py:
(ReadonlyDecoratorTransportTest.test_local_parameters,
FakeNFSDecoratorTests.test_http_parameters): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_sftp_transport.py:
(set_test_transport_to_sftp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

* bzrlib/tests/test_selftest.py:
(TestTestCaseWithTransport.test_get_readonly_url_http): Use
HttpServer from bzrlib.tests.HttpServer instead of
bzrlib.transport.http.

* bzrlib/tests/test_repository.py: 
Does *not* use HttpServer.

* bzrlib/tests/test_http.py: 
Build on top of bzrlib.tests.HttpServer and bzrlib.tests.HTTPUtils
instead of bzrlib.transport.http.

* bzrlib/tests/test_bzrdir.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_http.py:
(HTTPBranchTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/branch_implementations/test_branch.py:
(ChrootedTests.setUp): Use HttpServer from bzrlib.tests.HttpServer
instead of bzrlib.transport.http.

* bzrlib/tests/__init__.py:
(ChrootedTestCase.setUp): Use HttpServer from
bzrlib.tests.HttpServer instead of bzrlib.transport.http.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import os
27
27
from cStringIO import StringIO
28
28
 
29
 
from bzrlib import errors
 
29
from bzrlib import (
 
30
    errors,
 
31
    __version__ as bzrlib_version,
 
32
    )
30
33
import bzrlib
31
 
from bzrlib.errors import (TransportNotPossible, NoSuchFile,
32
 
                           TransportError, ConnectionError,
 
34
from bzrlib.errors import (NoSuchFile,
 
35
                           ConnectionError,
33
36
                           DependencyNotPresent)
34
37
from bzrlib.trace import mutter
35
38
from bzrlib.transport import register_urlparse_netloc_protocol
36
 
from bzrlib.transport.http import (HttpTransportBase, HttpServer,
37
 
                                   _extract_headers,
38
 
                                   response, _pycurl_errors)
 
39
from bzrlib.transport.http import (
 
40
    _extract_headers,
 
41
    HttpTransportBase,
 
42
    _pycurl_errors,
 
43
    response,
 
44
    )
39
45
 
40
46
try:
41
47
    import pycurl
157
163
        if code == 404:
158
164
            raise NoSuchFile(abspath)
159
165
        if code != 200:
160
 
            self._raise_curl_http_error(curl, 'expected 200 or 404 for full response.')
 
166
            self._raise_curl_http_error(
 
167
                curl, 'expected 200 or 404 for full response.')
161
168
 
162
169
        return code, data
163
170
 
228
235
            raise
229
236
 
230
237
 
231
 
class HttpServer_PyCurl(HttpServer):
232
 
    """Subclass of HttpServer that gives http+pycurl urls.
233
 
 
234
 
    This is for use in testing: connections to this server will always go
235
 
    through pycurl where possible.
236
 
    """
237
 
 
238
 
    # urls returned by this server should require the pycurl client impl
239
 
    _url_protocol = 'http+pycurl'
240
 
 
241
 
 
242
238
def get_test_permutations():
243
239
    """Return the permutations to be used in testing."""
 
240
    from bzrlib.tests.HttpServer import HttpServer_PyCurl
244
241
    return [(PyCurlTransport, HttpServer_PyCurl),
245
242
            ]