twisted.test.test_ftp.FTPClientTests(unittest.TestCase) class documentationtwisted.test.test_ftp
(View In Hierarchy)
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.renameissues RNTO and RNFR commands and returns aDeferredwhich
fires when a file has successfully been renamed. | 
| Method | test_renameFromToEscapesPaths | ftp.FTPClient.renameissues RNTO and RNFR commands with paths escaped according to
http://cr.yp.to/ftp/filesystem.html. | 
| Method | test_renameFromToFailingOnFirstError | The Deferredreturned byftp.FTPClient.renameis errbacked withCommandFailedif the RNFR command 
receives an error response code (for example, because the file does not 
exist). | 
| Method | test_renameFromToFailingOnRenameTo | The Deferredreturned byftp.FTPClient.renameis errbacked withCommandFailedif the RNTO command 
receives an error response code (for example, because the destination 
directory does not exist). | 
| Method | test_makeDirectory | ftp.FTPClient.makeDirectoryissues a MKD command and returns aDeferredwhich
is called back with the server's response if the directory is created. | 
| Method | test_makeDirectoryPathEscape | ftp.FTPClient.makeDirectoryescapes the path name it sends according to http://cr.yp.to/ftp/filesystem.html. | 
| Method | test_failedMakeDirectory | ftp.FTPClient.makeDirectoryreturns aDeferredwhich
is errbacked withCommandFailedif 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.removeFilesends 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 Deferredreturned byftp.FTPClient.removeFileis errbacked with aBadResponsecontaining the response. | 
| Method | test_multilineRemoveFileResponse | If the server returns multiple response lines, the Deferredreturned byftp.FTPClient.removeFileis still fired with a true value if the ultimate response code is 250. | 
| Method | test_removeDirectory | ftp.FTPClient.removeDirectorysends 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 Deferredreturned byftp.FTPClient.removeDirectoryis errbacked with aBadResponsecontaining the response. | 
| Method | test_multilineRemoveDirectoryResponse | If the server returns multiple response lines, the Deferredreturned byftp.FTPClient.removeDirectoryis 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 timeoutseconds. If not set, 
util.DEFAULT_TIMEOUT_DURATION is used. | 
| Method | __init__ | Construct an asynchronous test case for methodName. | 
| Method | assertFailure | Fail if deferreddoes not errback with one ofexpectedFailures. 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,crashandstoponreactor. 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 _deprecateReactordid. | 
| Method | _runCleanups | Run the cleanups added with addCleanupin order. | 
| Method | _runFixturesAndTest | Really run setUp, the test method, andtearDown.  Any of these may returndefer.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 | Noneor 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 theTestResultsupports skipping). | 
| Instance Variable | todo | None,
a string or a tuple of(errors, reason)whereerrorsis either an exception class or an iterable of 
exception classes, andreasonis a string. SeeTodoormakeTodofor 
more information. | 
| Instance Variable | suppress | Noneor a list of tuples of(args, kwargs)to be passed towarnings.filterwarnings. Use these to suppress warnings raised
in a test. Useful for testing deprecated code. See alsoutil.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 methodNameargument is passed to the constructor,runwill 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 conditionevaluates to True. | 
| Method | assertTrue | Fail the test if conditionevaluates to False. | 
| Method | assertRaises | Fail the test unless calling the function fwith the givenargsandkwargsraisesexception. 
The failure will report the traceback and call stack of the unexpected 
exception. | 
| Method | assertEqual | Fail the test if firstandsecondare not 
equal. | 
| Method | assertIs | Fail the test if firstis notsecond.  This is
an obect-identity-equality test, not an object equality (i.e.__eq__) test. | 
| Method | assertIsNot | Fail the test if firstissecond.  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 containeeis not found incontainer. | 
| Method | assertNotIn | Fail the test if containeeis found incontainer. | 
| 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 substringdoes not exist withinastring. | 
| Method | assertNotSubstring | Fail if astringcontainssubstring. | 
| 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 instanceis not an instance of the given class or 
of one of the given classes. | 
| Method | assertNotIsInstance | Fail if instanceis an instance of the given class or of 
one of the given classes. | 
| Method | successResultOf | Return the current success result of deferredor raiseself.failureException. | 
| Method | failureResultOf | Return the current failure result of deferredor raiseself.failureException. | 
| Method | assertNoResult | Assert that deferreddoes not have a result at this 
point. | 
| Method | assertRegex | Fail the test if a regexpsearch oftextfails. | 
Deliver disconnection notification to the client so that it can perform any cleanup which may be required.
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)
Test ftp.FTPClient.cdup's
handling of a failed CDUP command.
When the CDUP command fails, the returned Deferred should errback with 
ftp.CommandFailed.
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)
Test a failure in PWD command.
When the PWD command fails, the returned Deferred should errback with ftp.CommandFailed.
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)
Test a failure in CWD command.
When the PWD command fails, the returned Deferred should errback with ftp.CommandFailed.
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)
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.
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.
Try a RETR, but disconnect during the transfer.
L{ftp.FTPClient.retrieveFile} should return a Deferred which
errbacks with L{ftp.ConnectionLost)
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).
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.
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.
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)
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.
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.
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.
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.
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.
ftp.FTPClient.rename
issues RNTO and RNFR commands and returns a Deferred which
fires when a file has successfully been renamed.
ftp.FTPClient.rename
issues RNTO and RNFR commands with paths escaped according to
http://cr.yp.to/ftp/filesystem.html.
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).
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).
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.
ftp.FTPClient.makeDirectory
escapes the path name it sends according to http://cr.yp.to/ftp/filesystem.html.
ftp.FTPClient.makeDirectory
returns a Deferred which
is errbacked with CommandFailed if the server returns an error
response code.
Test the getDirectory method.
ftp.FTPClient.getDirectory
should return a Deferred which fires with the current directory on the 
server. It wraps PWD command.
Test a failure in getDirectory method.
The behaviour should be the same as PWD.
Test a different failure in getDirectory method.
The response should be quoted to be parsed, so it returns an error otherwise.
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.
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.
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.
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.
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.
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.
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.