~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server/pyftpdlib_based.py

  • Committer: Andrew Bennetts
  • Date: 2010-02-12 04:33:05 UTC
  • mfrom: (5031 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5032.
  • Revision ID: andrew.bennetts@canonical.com-20100212043305-ujdbsdoviql2t7i3
MergeĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib import (
30
30
    osutils,
31
31
    trace,
32
 
    transport,
33
32
    )
 
33
from bzrlib.tests import test_server
34
34
 
35
35
 
36
36
class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):
50
50
 
51
51
    def listdir(self, path):
52
52
        """List the content of a directory."""
53
 
        # FIXME: need tests with unicode paths
54
53
        return [osutils.safe_utf8(s) for s in os.listdir(path)]
55
54
 
56
55
    def fs2ftp(self, fspath):
57
 
        p = ftpserver.AbstractedFS.fs2ftp(self, fspath)
58
 
        # FIXME: need tests with unicode paths
 
56
        p = ftpserver.AbstractedFS.fs2ftp(self, osutils.safe_unicode(fspath))
59
57
        return osutils.safe_utf8(p)
60
58
 
 
59
    def ftp2fs(self, ftppath):
 
60
        p = osutils.safe_unicode(ftppath)
 
61
        return ftpserver.AbstractedFS.ftp2fs(self, p)
61
62
 
62
63
class BzrConformingFTPHandler(ftpserver.FTPHandler):
63
64
 
132
133
        self.addr = self.socket.getsockname()
133
134
 
134
135
 
135
 
class FTPTestServer(transport.Server):
 
136
class FTPTestServer(test_server.TestServer):
136
137
    """Common code for FTP server facilities."""
137
138
 
138
139
    def __init__(self):
156
157
        """This is used by ftp_server to log connections, etc."""
157
158
        self.logs.append(message)
158
159
 
159
 
    def setUp(self, vfs_server=None):
160
 
        from bzrlib.transport.local import LocalURLServer
161
 
        if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):
 
160
    def start_server(self, vfs_server=None):
 
161
        if not (vfs_server is None or isinstance(vfs_server,
 
162
                                                 test_server.LocalURLServer)):
162
163
            raise AssertionError(
163
164
                "FTPServer currently assumes local transport, got %s"
164
165
                % vfs_server)
186
187
        self._ftpd_starting.acquire()
187
188
        self._ftpd_starting.release()
188
189
 
189
 
    def tearDown(self):
190
 
        """See bzrlib.transport.Server.tearDown."""
 
190
    def stop_server(self):
 
191
        """See bzrlib.transport.Server.stop_server."""
191
192
        # Tell the server to stop, but also close the server socket for tests
192
193
        # that start the server but never initiate a connection. Closing the
193
194
        # socket should be done first though, to avoid further connections.
196
197
        self._ftpd_thread.join()
197
198
 
198
199
    def _run_server(self):
199
 
        """Run the server until tearDown is called, shut it down properly then.
 
200
        """Run the server until stop_server is called, shut it down properly then.
200
201
        """
201
202
        self._ftpd_running = True
202
203
        self._ftpd_starting.release()