/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Vincent Ladeuil
  • Date: 2008-12-04 17:12:46 UTC
  • mto: (3902.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3903.
  • Revision ID: v.ladeuil+lp@free.fr-20081204171246-p28b3u0e2alz53iv
Fix bug #270863 by preserving 'bzr+http[s]' decorator.

* bzrlib/transport/remote.py:
(RemoteHTTPTransport._redirected_to): Specific implementation to
handle the redirections.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib.__init__): Fix parameter order.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport.__init__): Fix parameter order.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase.external_url): Semi drive-by fix, external_url
shouldn't expose the implementation qualifier (it's private to bzr
not externally usable).

* bzrlib/transport/decorator.py:
(TransportDecorator._redirected_to): Cleanup.

* bzrlib/tests/test_smart_transport.py:
(RemoteHTTPTransportTestCase): Add specific tests for
_redirected_to.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3357
3357
        # requests for child URLs of that to the original URL.  i.e., we want to
3358
3358
        # POST to "bzr+http://host/foo/.bzr/smart" and never something like
3359
3359
        # "bzr+http://host/foo/.bzr/branch/.bzr/smart".  So, a cloned
3360
 
        # RemoteHTTPTransport remembers the initial URL, and adjusts the relpaths
3361
 
        # it sends in smart requests accordingly.
 
3360
        # RemoteHTTPTransport remembers the initial URL, and adjusts the
 
3361
        # relpaths it sends in smart requests accordingly.
3362
3362
        base_transport = remote.RemoteHTTPTransport('bzr+http://host/path')
3363
3363
        new_transport = base_transport.clone('child_dir')
3364
3364
        self.assertEqual(base_transport._http_transport,
3384
3384
            'c/',
3385
3385
            new_transport._client.remote_path_from_transport(new_transport))
3386
3386
 
3387
 
        
 
3387
    def test__redirect_to(self):
 
3388
        t = remote.RemoteHTTPTransport('bzr+http://www.example.com/foo')
 
3389
        r = t._redirected_to('http://www.example.com/foo',
 
3390
                             'http://www.example.com/bar')
 
3391
        self.assertEquals(type(r), type(t))
 
3392
 
 
3393
    def test__redirect_sibling_protocol(self):
 
3394
        t = remote.RemoteHTTPTransport('bzr+http://www.example.com/foo')
 
3395
        r = t._redirected_to('http://www.example.com/foo',
 
3396
                             'https://www.example.com/bar')
 
3397
        self.assertEquals(type(r), type(t))
 
3398
        self.assertStartsWith(r.base, 'bzr+https')
 
3399
 
 
3400
    def test__redirect_to_with_user(self):
 
3401
        t = remote.RemoteHTTPTransport('bzr+http://joe@www.example.com/foo')
 
3402
        r = t._redirected_to('http://www.example.com/foo',
 
3403
                             'http://www.example.com/bar')
 
3404
        self.assertEquals(type(r), type(t))
 
3405
        self.assertEquals('joe', t._user)
 
3406
        self.assertEquals(t._user, r._user)
 
3407
 
 
3408
    def test_redirected_to_same_host_different_protocol(self):
 
3409
        t = remote.RemoteHTTPTransport('bzr+http://joe@www.example.com/foo')
 
3410
        r = t._redirected_to('http://www.example.com/foo',
 
3411
                             'ftp://www.example.com/foo')
 
3412
        self.assertNotEquals(type(r), type(t))
 
3413
 
 
3414
 
3388
3415
# TODO: Client feature that does get_bundle and then installs that into a
3389
3416
# branch; this can be used in place of the regular pull/fetch operation when
3390
3417
# coming from a smart server.