Rev 2415: (John Arbash Meinel) Update FtpServer for setUp(vfs_server), and MedusaFeature in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 13 15:34:32 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2415
revision-id: pqm at pqm.ubuntu.com-20070413143426-6aj60em3rta94aw0
parent: pqm at pqm.ubuntu.com-20070413050623-10v4wozs1tu04kcu
parent: john at arbash-meinel.com-20070412211829-dduwktk8in0e6zpl
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-04-13 15:34:26 +0100
message:
(John Arbash Meinel) Update FtpServer for setUp(vfs_server), and MedusaFeature
modified:
bzrlib/tests/test_ftp_transport.py test_aftp_transport.-20060823221619-98mwjzxtwtkt527k-1
bzrlib/transport/ftp.py ftp.py-20051116161804-58dc9506548c2a53
------------------------------------------------------------
revno: 2413.1.2
merged: john at arbash-meinel.com-20070412211829-dduwktk8in0e6zpl
parent: john at arbash-meinel.com-20070412205634-so7gafs8m0xc7v8x
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: test_case_with_ftp_server
timestamp: Thu 2007-04-12 16:18:29 -0500
message:
Clean up test ordering
------------------------------------------------------------
revno: 2413.1.1
merged: john at arbash-meinel.com-20070412205634-so7gafs8m0xc7v8x
parent: pqm at pqm.ubuntu.com-20070412150356-jeie6iap22sae8xf
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: test_case_with_ftp_server
timestamp: Thu 2007-04-12 15:56:34 -0500
message:
Implement TestCaseWithFTPServer using the new shiny Feature mechanism.
Also update FtpServer so that it conforms to the expected setUp(vfs_server)
functionality.
=== modified file 'bzrlib/tests/test_ftp_transport.py'
--- a/bzrlib/tests/test_ftp_transport.py 2006-10-05 05:37:25 +0000
+++ b/bzrlib/tests/test_ftp_transport.py 2007-04-12 21:18:29 +0000
@@ -14,11 +14,43 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib import tests
import bzrlib.transport
-class TestCaseAFTP(TestCaseWithTransport):
+class _MedusaFeature(tests.Feature):
+ """Some tests want an FTP Server, check if one is available.
+
+ Right now, the only way this is available is if 'medusa' is installed.
+ """
+
+ def _probe(self):
+ try:
+ import medusa
+ import medusa.filesys
+ import medusa.ftp_server
+ return True
+ except ImportError:
+ return False
+
+ def feature_name(self):
+ return 'medusa'
+
+MedusaFeature = _MedusaFeature()
+
+
+class TestCaseWithFTPServer(tests.TestCaseWithTransport):
+
+ _test_needs_features = [MedusaFeature]
+
+ def setUp(self):
+ from bzrlib.transport.ftp import FtpServer
+ self.transport_server = FtpServer
+ super(TestCaseWithFTPServer, self).setUp()
+
+
+
+class TestCaseAFTP(tests.TestCaseWithTransport):
"""Test aftp transport."""
def test_aftp_degrade(self):
@@ -28,3 +60,14 @@
self.failUnless(parent.is_active)
self.assertEqual('aftp://host/path', t.abspath(''))
+
+
+class TestFTPServer(TestCaseWithFTPServer):
+
+ def test_basic_exists(self):
+ url = self.get_url()
+ self.assertStartsWith(url, 'ftp://')
+
+ t = self.get_transport()
+ t.put_bytes('foo', 'test bytes\n')
+ self.assertEqual('test bytes\n', t.get_bytes('foo'))
=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py 2007-03-13 17:00:20 +0000
+++ b/bzrlib/transport/ftp.py 2007-04-12 20:56:34 +0000
@@ -47,6 +47,7 @@
split_url,
Transport,
)
+from bzrlib.transport.local import LocalURLServer
import bzrlib.ui
_have_medusa = False
@@ -550,11 +551,13 @@
"""This is used by medusa.ftp_server to log connections, etc."""
self.logs.append(message)
- def setUp(self):
-
+ def setUp(self, vfs_server=None):
if not _have_medusa:
raise RuntimeError('Must have medusa to run the FtpServer')
+ assert vfs_server is None or isinstance(vfs_server, LocalURLServer), \
+ "FtpServer currently assumes local transport, got %s" % vfs_server
+
self._root = os.getcwdu()
self._ftp_server = _ftp_server(
authorizer=_test_authorizer(root=self._root),
More information about the bazaar-commits
mailing list