~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-02-04 17:41:12 UTC
  • mto: (2323.7.1 redirection)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: v.ladeuil+lp@free.fr-20070204174112-iv6gxzinnjddlaxj
Add tests for redirection. Preserve transport decorations.

* bzrlib/tests/test_http.py:
(TestRedirections): new tests.

* bzrlib/tests/HttpServer.py:
(HttpServer): Make server host and port public once the socket
have been established.

* bzrlib/tests/HTTPTestUtil.py:
(RedirectRequestHandler, HTTPServerRedirecting): New http test
server for redirections. Only a whole host can be redirected, so
far.

* bzrlib/errors.py:
(RedirectRequested.__init__): Add a 'qual_proto' oso that
transport decorations can be transmitted to redirected transport.
(RedirectRequested._requalify_url,
RedirectRequested.get_source_url,
RedirectRequested.get_target_url): New methods providing fully
decorated urls.

* bzrlib/bzrdir.py:
(BzrDir.open_from_transport): The redirection should preserve
transport decorations.
(BzrDirMetaFormat1): To be able to specialize bzr branches from
foreign branches, we need to register BzrDirMetaFormat1 as the
default control format (instead of BzrDirMetaFormat which is
abstract and can still be used by foreign branches).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1478
1478
            'Content-Length: 6\r\n'
1479
1479
            '\r\n'
1480
1480
            'hello\n')
1481
 
        request_handler = SmartRequestHandler(
1482
 
            socket, ('localhost', 80), httpd)
 
1481
        # Beware: the ('localhost', 80) below is the
 
1482
        # client_address parameter, but we don't have one because
 
1483
        # we have defined a socket which is not bind to an
 
1484
        # address. The test framework never uses this client
 
1485
        # address, so far...
 
1486
        request_handler = SmartRequestHandler(socket, ('localhost', 80), httpd)
1483
1487
        response = socket.writefile.getvalue()
1484
1488
        self.assertStartsWith(response, 'HTTP/1.0 200 ')
1485
1489
        # This includes the end of the HTTP headers, and all the body.