~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ftp_transport.py

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from cStringIO import StringIO
18
17
import ftplib
19
18
import getpass
20
 
import sys
 
19
import urllib
21
20
 
22
21
from bzrlib import (
23
22
    config,
45
44
    """Test aftp transport."""
46
45
 
47
46
    def test_aftp_degrade(self):
48
 
        t = transport.get_transport('aftp://host/path')
49
 
        self.failUnless(t.is_active)
 
47
        t = transport.get_transport_from_url('aftp://host/path')
 
48
        self.assertTrue(t.is_active)
50
49
        parent = t.clone('..')
51
 
        self.failUnless(parent.is_active)
 
50
        self.assertTrue(parent.is_active)
52
51
 
53
52
        self.assertEqual('aftp://host/path', t.abspath(''))
54
53
 
83
82
    def get_url(self, relpath=None):
84
83
        """Overrides get_url to inject our user."""
85
84
        base = super(TestFTPTestServerUI, self).get_url(relpath)
86
 
        (scheme, user, password,
87
 
         host, port, path) = transport.ConnectedTransport._split_url(base)
88
 
        url = transport.ConnectedTransport._unsplit_url(
89
 
            scheme, self.user, self.password, host, port, path)
90
 
        return url
 
85
        parsed_url = transport.ConnectedTransport._split_url(base)
 
86
        new_url = parsed_url.clone()
 
87
        new_url.user = self.user
 
88
        new_url.quoted_user = urllib.quote(self.user)
 
89
        new_url.password = self.password
 
90
        new_url.quoted_password = urllib.quote(self.password)
 
91
        return str(new_url)
91
92
 
92
93
    def test_no_prompt_for_username(self):
93
94
        """ensure getpass.getuser() is used if there's no username in the