Test advanced FTP client commands.

Method setUp Create a FTP client and connect it to fake transport.
Method tearDown Deliver disconnection notification to the client so that it can perform any cleanup which may be required.
Method test_sendLine Test encoding behaviour of sendLine
Method test_CDUP Test the CDUP command.
Method test_failedCDUP Test ftp.FTPClient.cdup's handling of a failed CDUP command.
Method test_PWD Test the PWD command.
Method test_failedPWD Test a failure in PWD command.
Method test_CWD Test the CWD command.
Method test_failedCWD Test a failure in CWD command.
Method test_passiveRETR Test the RETR command in passive mode: get a file and verify its content.
Method test_RETR Test the RETR command in non-passive mode.
Method test_failedRETR Try to RETR an unexisting file.
Method test_lostRETR Try a RETR, but disconnect during the transfer. L{ftp.FTPClient.retrieveFile} should return a Deferred which errbacks with L{ftp.ConnectionLost)
Method test_passiveSTOR Test the STOR command: send a file and verify its content.
Method test_failedSTOR Test a failure in the STOR command.
Method test_STOR Test the STOR command in non-passive mode.
Method test_passiveLIST Test the LIST command.
Method test_LIST Test the LIST command in non-passive mode.
Method test_failedLIST Test a failure in LIST command.
Method test_NLST Test the NLST command in non-passive mode.
Method test_passiveNLST Test the NLST command.
Method test_failedNLST Test a failure in NLST command.
Method test_renameFromTo ftp.FTPClient.rename issues RNTO and RNFR commands and returns a Deferred which fires when a file has successfully been renamed.
Method test_renameFromToEscapesPaths ftp.FTPClient.rename issues RNTO and RNFR commands with paths escaped according to http://cr.yp.to/ftp/filesystem.html.
Method test_renameFromToFailingOnFirstError The Deferred returned by ftp.FTPClient.rename is errbacked with CommandFailed if the RNFR command receives an error response code (for example, because the file does not exist).
Method test_renameFromToFailingOnRenameTo The Deferred returned by ftp.FTPClient.rename is errbacked with CommandFailed if the RNTO command receives an error response code (for example, because the destination directory does not exist).
Method test_makeDirectory ftp.FTPClient.makeDirectory issues a MKD command and returns a Deferred which is called back with the server's response if the directory is created.
Method test_makeDirectoryPathEscape ftp.FTPClient.makeDirectory escapes the path name it sends according to http://cr.yp.to/ftp/filesystem.html.
Method test_failedMakeDirectory ftp.FTPClient.makeDirectory returns a Deferred which is errbacked with CommandFailed if the server returns an error response code.
Method test_getDirectory Test the getDirectory method.
Method test_failedGetDirectory Test a failure in getDirectory method.
Method test_anotherFailedGetDirectory Test a different failure in getDirectory method.
Method test_removeFile ftp.FTPClient.removeFile sends a DELE command to the server for the indicated file and returns a Deferred which fires after the server sends a 250 response code.
Method test_failedRemoveFile No summary
Method test_unparsableRemoveFileResponse If the server returns a response line which cannot be parsed, the Deferred returned by ftp.FTPClient.removeFile is errbacked with a BadResponse containing the response.
Method test_multilineRemoveFileResponse If the server returns multiple response lines, the Deferred returned by ftp.FTPClient.removeFile is still fired with a true value if the ultimate response code is 250.
Method test_removeDirectory ftp.FTPClient.removeDirectory sends a RMD command to the server for the indicated directory and returns a Deferred which fires after the server sends a 250 response code.
Method test_failedRemoveDirectory No summary
Method test_unparsableRemoveDirectoryResponse If the server returns a response line which cannot be parsed, the Deferred returned by ftp.FTPClient.removeDirectory is errbacked with a BadResponse containing the response.
Method test_multilineRemoveDirectoryResponse If the server returns multiple response lines, the Deferred returned by ftp.FTPClient.removeDirectory is still fired with a true value if the ultimate response code is 250.
Method _testLogin Test the login part.

Inherited from TestCase:

Instance Variable timeout A real number of seconds. If set, the test will raise an error if it takes longer than timeout seconds. If not set, util.DEFAULT_TIMEOUT_DURATION is used.
Method __init__ Construct an asynchronous test case for methodName.
Method assertFailure Fail if deferred does not errback with one of expectedFailures. Returns the original Deferred with callbacks added. You will need to return this Deferred from your test case.
Method __call__ Run the test. Should always do exactly the same thing as run().
Method deferSetUp Undocumented
Method deferTestMethod Undocumented
Method deferTearDown Undocumented
Method deferRunCleanups Run any scheduled cleanups and report errors (if any to the result object.
Method addCleanup Extend the base cleanup feature with support for cleanup functions which return Deferreds.
Method getSuppress Undocumented
Method getTimeout No summary
Method _run Run a single method, either a test method or fixture.
Method _ebDeferSetUp Undocumented
Method _cbDeferTestMethod Undocumented
Method _ebDeferTestMethod Undocumented
Method _ebDeferTearDown Undocumented
Method _cbDeferRunCleanups Undocumented
Method _cleanUp Undocumented
Method _classCleanUp Undocumented
Method _makeReactorMethod Create a method which wraps the reactor method name. The new method issues a deprecation warning and calls the original.
Method _deprecateReactor Deprecate iterate, crash and stop on reactor. That is, each method is wrapped in a function that issues a deprecation warning, then calls the original.
Method _undeprecateReactor Restore the deprecated reactor methods. Undoes what _deprecateReactor did.
Method _runCleanups Run the cleanups added with addCleanup in order.
Method _runFixturesAndTest Really run setUp, the test method, and tearDown. Any of these may return defer.Deferreds. After they complete, do some reactor cleanup.
Method _wait Take a Deferred that only ever callbacks. Block until it happens.

Inherited from SynchronousTestCase (via TestCase):

Instance Variable failureException An exception class, defaulting to FailTest. If the test method raises this exception, it will be reported as a failure, rather than an exception. All of the assertion methods raise this if the assertion fails.
Instance Variable skip None or a string explaining why this test is to be skipped. If defined, the test will not be run. Instead, it will be reported to the result object as 'skipped' (if the TestResult supports skipping).
Instance Variable todo None, a string or a tuple of (errors, reason) where errors is either an exception class or an iterable of exception classes, and reason is a string. See Todo or makeTodo for more information.
Instance Variable suppress None or a list of tuples of (args, kwargs) to be passed to warnings.filterwarnings. Use these to suppress warnings raised in a test. Useful for testing deprecated code. See also util.suppress.
Method __eq__ No summary
Method __ne__ Undocumented
Method __hash__ Undocumented
Method shortDescription Undocumented
Method getSkip No summary
Method getTodo No summary
Method runTest If no methodName argument is passed to the constructor, run will treat this method as the thing with the actual test inside.
Method run Run the test case, storing the results in result.
Method patch Monkey patch an object for the duration of the test.
Method flushLoggedErrors Remove stored errors received from the log.
Method flushWarnings Remove stored warnings from the list of captured warnings and return them.
Method callDeprecated Call a function that should have been deprecated at a specific version and in favor of a specific alternative, and assert that it was thusly deprecated.
Method mktemp Create a new path name which can be used for a new file or directory.
Method _getSuppress No summary
Method _getSkipReason Return the reason to use for skipping a test method.
Method _installObserver Undocumented
Method _removeObserver Undocumented

Inherited from _Assertions (via TestCase, SynchronousTestCase):

Method fail Absolutely fail the test. Do not pass go, do not collect $200.
Method assertFalse Fail the test if condition evaluates to True.
Method assertTrue Fail the test if condition evaluates to False.
Method assertRaises Fail the test unless calling the function f with the given args and kwargs raises exception. The failure will report the traceback and call stack of the unexpected exception.
Method assertEqual Fail the test if first and second are not equal.
Method assertIs Fail the test if first is not second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test.
Method assertIsNot Fail the test if first is second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test.
Method assertNotEqual Fail the test if first == second.
Method assertIn Fail the test if containee is not found in container.
Method assertNotIn Fail the test if containee is found in container.
Method assertNotAlmostEqual Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
Method assertAlmostEqual Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
Method assertApproximates Fail if first - second > tolerance
Method assertSubstring Fail if substring does not exist within astring.
Method assertNotSubstring Fail if astring contains substring.
Method assertWarns Fail if the given function doesn't generate the specified warning when called. It calls the function, checks the warning, and forwards the result of the function if everything is fine.
Method assertIsInstance Fail if instance is not an instance of the given class or of one of the given classes.
Method assertNotIsInstance Fail if instance is an instance of the given class or of one of the given classes.
Method successResultOf Return the current success result of deferred or raise self.failureException.
Method failureResultOf Return the current failure result of deferred or raise self.failureException.
Method assertNoResult Assert that deferred does not have a result at this point.
Method assertRegex Fail the test if a regexp search of text fails.
def setUp(self):

Create a FTP client and connect it to fake transport.

def tearDown(self):

Deliver disconnection notification to the client so that it can perform any cleanup which may be required.

def _testLogin(self):

Test the login part.

def test_sendLine(self):

Test encoding behaviour of sendLine

def test_CDUP(self):

Test the CDUP command.

ftp.FTPClient.cdup should return a Deferred which fires with a sequence of one element which is the string the server sent indicating that the command was executed successfully.

(XXX - This is a bad API)

def test_failedCDUP(self):

Test ftp.FTPClient.cdup's handling of a failed CDUP command.

When the CDUP command fails, the returned Deferred should errback with ftp.CommandFailed.

def test_PWD(self):

Test the PWD command.

ftp.FTPClient.pwd should return a Deferred which fires with a sequence of one element which is a string representing the current working directory on the server.

(XXX - This is a bad API)

def test_failedPWD(self):

Test a failure in PWD command.

When the PWD command fails, the returned Deferred should errback with ftp.CommandFailed.

def test_CWD(self):

Test the CWD command.

ftp.FTPClient.cwd should return a Deferred which fires with a sequence of one element which is the string the server sent indicating that the command was executed successfully.

(XXX - This is a bad API)

def test_failedCWD(self):

Test a failure in CWD command.

When the PWD command fails, the returned Deferred should errback with ftp.CommandFailed.

def test_passiveRETR(self):

Test the RETR command in passive mode: get a file and verify its content.

ftp.FTPClient.retrieveFile should return a Deferred which fires with the protocol instance passed to it after the download has completed.

(XXX - This API should be based on producers and consumers)

def test_RETR(self):

Test the RETR command in non-passive mode.

Like test_passiveRETR but in the configuration where the server establishes the data connection to the client, rather than the other way around.

def test_failedRETR(self):

Try to RETR an unexisting file.

ftp.FTPClient.retrieveFile should return a Deferred which errbacks with ftp.CommandFailed if the server indicates the file cannot be transferred for some reason.

def test_lostRETR(self):
Try a RETR, but disconnect during the transfer.
L{ftp.FTPClient.retrieveFile} should return a Deferred which
errbacks with L{ftp.ConnectionLost)
def test_passiveSTOR(self):

Test the STOR command: send a file and verify its content.

ftp.FTPClient.storeFile should return a two-tuple of Deferreds. The first of which should fire with a protocol instance when the data connection has been established and is responsible for sending the contents of the file. The second of which should fire when the upload has completed, the data connection has been closed, and the server has acknowledged receipt of the file.

(XXX - storeFile should take a producer as an argument, instead, and only return a Deferred which fires when the upload has succeeded or failed).

def test_failedSTOR(self):

Test a failure in the STOR command.

If the server does not acknowledge successful receipt of the uploaded file, the second Deferred returned by ftp.FTPClient.storeFile should errback with ftp.CommandFailed.

def test_STOR(self):

Test the STOR command in non-passive mode.

Like test_passiveSTOR but in the configuration where the server establishes the data connection to the client, rather than the other way around.

def test_passiveLIST(self):

Test the LIST command.

ftp.FTPClient.list should return a Deferred which fires with a protocol instance which was passed to list after the command has succeeded.

(XXX - This is a very unfortunate API; if my understanding is correct, the results are always at least line-oriented, so allowing a per-line parser function to be specified would make this simpler, but a default implementation should really be provided which knows how to deal with all the formats used in real servers, so application developers never have to care about this insanity. It would also be nice to either get back a Deferred of a list of filenames or to be able to consume the files as they are received (which the current API does allow, but in a somewhat inconvenient fashion) -exarkun)

def test_LIST(self):

Test the LIST command in non-passive mode.

Like test_passiveLIST but in the configuration where the server establishes the data connection to the client, rather than the other way around.

def test_failedLIST(self):

Test a failure in LIST command.

ftp.FTPClient.list should return a Deferred which fails with ftp.CommandFailed if the server indicates the indicated path is invalid for some reason.

def test_NLST(self):

Test the NLST command in non-passive mode.

ftp.FTPClient.nlst should return a Deferred which fires with a list of filenames when the list command has completed.

def test_passiveNLST(self):

Test the NLST command.

Like test_passiveNLST but in the configuration where the server establishes the data connection to the client, rather than the other way around.

def test_failedNLST(self):

Test a failure in NLST command.

ftp.FTPClient.nlst should return a Deferred which fails with ftp.CommandFailed if the server indicates the indicated path is invalid for some reason.

def test_renameFromTo(self):

ftp.FTPClient.rename issues RNTO and RNFR commands and returns a Deferred which fires when a file has successfully been renamed.

def test_renameFromToEscapesPaths(self):

ftp.FTPClient.rename issues RNTO and RNFR commands with paths escaped according to http://cr.yp.to/ftp/filesystem.html.

def test_renameFromToFailingOnFirstError(self):

The Deferred returned by ftp.FTPClient.rename is errbacked with CommandFailed if the RNFR command receives an error response code (for example, because the file does not exist).

def test_renameFromToFailingOnRenameTo(self):

The Deferred returned by ftp.FTPClient.rename is errbacked with CommandFailed if the RNTO command receives an error response code (for example, because the destination directory does not exist).

def test_makeDirectory(self):

ftp.FTPClient.makeDirectory issues a MKD command and returns a Deferred which is called back with the server's response if the directory is created.

def test_makeDirectoryPathEscape(self):

ftp.FTPClient.makeDirectory escapes the path name it sends according to http://cr.yp.to/ftp/filesystem.html.

def test_failedMakeDirectory(self):

ftp.FTPClient.makeDirectory returns a Deferred which is errbacked with CommandFailed if the server returns an error response code.

def test_getDirectory(self):

Test the getDirectory method.

ftp.FTPClient.getDirectory should return a Deferred which fires with the current directory on the server. It wraps PWD command.

def test_failedGetDirectory(self):

Test a failure in getDirectory method.

The behaviour should be the same as PWD.

def test_anotherFailedGetDirectory(self):

Test a different failure in getDirectory method.

The response should be quoted to be parsed, so it returns an error otherwise.

def test_removeFile(self):

ftp.FTPClient.removeFile sends a DELE command to the server for the indicated file and returns a Deferred which fires after the server sends a 250 response code.

def test_failedRemoveFile(self):

If the server returns a response code other than 250 in response to a DELE sent by ftp.FTPClient.removeFile, the Deferred returned by removeFile is errbacked with a Failure wrapping a CommandFailed.

def test_unparsableRemoveFileResponse(self):

If the server returns a response line which cannot be parsed, the Deferred returned by ftp.FTPClient.removeFile is errbacked with a BadResponse containing the response.

def test_multilineRemoveFileResponse(self):

If the server returns multiple response lines, the Deferred returned by ftp.FTPClient.removeFile is still fired with a true value if the ultimate response code is 250.

def test_removeDirectory(self):

ftp.FTPClient.removeDirectory sends a RMD command to the server for the indicated directory and returns a Deferred which fires after the server sends a 250 response code.

def test_failedRemoveDirectory(self):

If the server returns a response code other than 250 in response to a RMD sent by ftp.FTPClient.removeDirectory, the Deferred returned by removeDirectory is errbacked with a Failure wrapping a CommandFailed.

def test_unparsableRemoveDirectoryResponse(self):

If the server returns a response line which cannot be parsed, the Deferred returned by ftp.FTPClient.removeDirectory is errbacked with a BadResponse containing the response.

def test_multilineRemoveDirectoryResponse(self):
If the server returns multiple response lines, the L{Deferred} returned
by L{ftp.FTPClient.removeDirectory} is still fired with a true value
 if the ultimate response code is 250.
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.