~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ftp_transport.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-28 15:04:17 UTC
  • mfrom: (2466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070428150417-trp3pi0pzd411pu4
[merge] bzr.dev 2466

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.tests import TestCaseWithTransport
 
17
from bzrlib import tests
18
18
import bzrlib.transport
19
19
 
20
20
 
21
 
class TestCaseAFTP(TestCaseWithTransport):
 
21
class _MedusaFeature(tests.Feature):
 
22
    """Some tests want an FTP Server, check if one is available.
 
23
 
 
24
    Right now, the only way this is available is if 'medusa' is installed.
 
25
    """
 
26
 
 
27
    def _probe(self):
 
28
        try:
 
29
            import medusa
 
30
            import medusa.filesys
 
31
            import medusa.ftp_server
 
32
            return True
 
33
        except ImportError:
 
34
            return False
 
35
 
 
36
    def feature_name(self):
 
37
        return 'medusa'
 
38
 
 
39
MedusaFeature = _MedusaFeature()
 
40
 
 
41
 
 
42
class TestCaseWithFTPServer(tests.TestCaseWithTransport):
 
43
 
 
44
    _test_needs_features = [MedusaFeature]
 
45
 
 
46
    def setUp(self):
 
47
        from bzrlib.transport.ftp import FtpServer
 
48
        self.transport_server = FtpServer
 
49
        super(TestCaseWithFTPServer, self).setUp()
 
50
 
 
51
 
 
52
 
 
53
class TestCaseAFTP(tests.TestCaseWithTransport):
22
54
    """Test aftp transport."""
23
55
 
24
56
    def test_aftp_degrade(self):
28
60
        self.failUnless(parent.is_active)
29
61
 
30
62
        self.assertEqual('aftp://host/path', t.abspath(''))
 
63
 
 
64
 
 
65
class TestFTPServer(TestCaseWithFTPServer):
 
66
 
 
67
    def test_basic_exists(self):
 
68
        url = self.get_url()
 
69
        self.assertStartsWith(url, 'ftp://')
 
70
 
 
71
        t = self.get_transport()
 
72
        t.put_bytes('foo', 'test bytes\n')
 
73
        self.assertEqual('test bytes\n', t.get_bytes('foo'))