~bzr-pqm/bzr/bzr.dev

2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2006 Canonical Ltd
2
#
1952.1.1 by John Arbash Meinel
Ghozzy: Fix Bzr's support of Active FTP (aftp://)
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
2413.1.1 by John Arbash Meinel
Implement TestCaseWithFTPServer using the new shiny Feature mechanism.
17
from bzrlib import tests
1952.1.1 by John Arbash Meinel
Ghozzy: Fix Bzr's support of Active FTP (aftp://)
18
import bzrlib.transport
19
20
2413.1.1 by John Arbash Meinel
Implement TestCaseWithFTPServer using the new shiny Feature mechanism.
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
2413.1.2 by John Arbash Meinel
Clean up test ordering
53
class TestCaseAFTP(tests.TestCaseWithTransport):
54
    """Test aftp transport."""
55
56
    def test_aftp_degrade(self):
57
        t = bzrlib.transport.get_transport('aftp://host/path')
58
        self.failUnless(t.is_active)
59
        parent = t.clone('..')
60
        self.failUnless(parent.is_active)
61
62
        self.assertEqual('aftp://host/path', t.abspath(''))
63
64
2413.1.1 by John Arbash Meinel
Implement TestCaseWithFTPServer using the new shiny Feature mechanism.
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'))