~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ftp_transport.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Canonical Ltd
 
2
#
1
3
# This program is free software; you can redistribute it and/or modify
2
4
# it under the terms of the GNU General Public License as published by
3
5
# the Free Software Foundation; either version 2 of the License, or
12
14
# along with this program; if not, write to the Free Software
13
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14
16
 
15
 
from bzrlib.tests import TestCaseWithTransport
 
17
from bzrlib import tests
16
18
import bzrlib.transport
17
19
 
18
20
 
19
 
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):
20
54
    """Test aftp transport."""
21
55
 
22
56
    def test_aftp_degrade(self):
26
60
        self.failUnless(parent.is_active)
27
61
 
28
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'))