1
# Copyright (C) 2009, 2010 Canonical Ltd
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
Facilities to use ftp test servers.
23
from bzrlib import tests
24
from bzrlib.tests import (
30
from bzrlib.tests.ftp_server import medusa_based
31
# medusa is bogus starting with python2.6, since we don't support earlier
32
# pythons anymore, it's currently useless. There is hope though that the
33
# unicode bugs get fixed in the future so we leave it disabled until
34
# then. Keeping the framework in place means that only the following line
35
# will need to be changed. The last tests were conducted with medusa-2.0
37
medusa_available = False
39
medusa_available = False
43
from bzrlib.tests.ftp_server import pyftpdlib_based
44
if pyftpdlib_based.pyftplib_version >= (0, 7, 0):
45
pyftpdlib_available = True
47
# 0.6.0 breaks SITE CHMOD
48
pyftpdlib_available = False
50
pyftpdlib_available = False
53
class _FTPServerFeature(features.Feature):
54
"""Some tests want an FTP Server, check if one is available.
56
Right now, the only way this is available is if one of the following is
59
- 'medusa': http://www.amk.ca/python/code/medusa.html
60
- 'pyftpdlib': http://code.google.com/p/pyftpdlib/
64
return medusa_available or pyftpdlib_available
66
def feature_name(self):
70
FTPServerFeature = _FTPServerFeature()
73
class UnavailableFTPTestServer(object):
74
"""Dummy ftp test server.
76
This allows the test suite report the number of tests needing that
77
feature. We raise UnavailableFeature from methods before the test server is
78
being used. Doing so in the setUp method has bad side-effects (tearDown is
82
def start_server(self, vfs_server=None):
85
def stop_server(self):
89
raise tests.UnavailableFeature(FTPServerFeature)
91
def get_bogus_url(self):
92
raise tests.UnavailableFeature(FTPServerFeature)
96
FTPTestServer = medusa_based.FTPTestServer
97
elif pyftpdlib_available:
98
FTPTestServer = pyftpdlib_based.FTPTestServer
100
FTPTestServer = UnavailableFTPTestServer