class documentation

class MultiPartProducerTestCase(unittest.TestCase): (source)

View In Hierarchy

Tests for the L{MultiPartProducer} which gets dictionary like object with post parameters, converts them to mutltipart/form-data format and feeds them to an L{IConsumer}.

Method getOutput A convenience function to consume and return outpute.
Method newLines Undocumented
Method setUp Create a L{Cooperator} hooked up to an easily controlled, deterministic scheduler to use with L{MultiPartProducer}.
Method test_defaultCooperator If no L{Cooperator} instance is passed to L{MultiPartProducer}, the global cooperator is used.
Method test_failedReadWhileProducing If a read from the input file fails while producing bytes to the consumer, the L{Deferred} returned by L{MultiPartProducer.startProducing} fires with a L{Failure} wrapping that exception.
Method test_failOnByteStrings If byte string is passed as a param and we don't know the encoding, fail early to prevent corrupted form posts
Method test_failOnUnknownParams If byte string is passed as a param and we don't know the encoding, fail early to prevent corrupted form posts
Method test_fieldsAndAttachment Make sure multiple fields are rendered properly.
Method test_inputClosedAtEOF When L{MultiPartProducer} reaches end-of-file on the input file given to it, the input file is closed.
Method test_interface L{MultiPartProducer} instances provide L{IBodyProducer}.
Method test_knownLengthOnFile If the L{MultiPartProducer} is constructed with a file-like object with both C{seek} and C{tell} methods, its C{length} attribute is set to the size of the file as determined by those methods.
Method test_missingAttachmentName Make sure attachments without names are supported
Method test_multipleFieldsAndAttachments Make sure multiple fields, attachments etc are rendered properly.
Method test_newLinesInParams Make sure we generate proper format even with newlines in attachments
Method test_pauseProducing L{MultiPartProducer.pauseProducing} temporarily suspends writing bytes from the input file to the given L{IConsumer}.
Method test_resumeProducing L{MultoPartProducer.resumeProducing} re-commences writing bytes from the input file to the given L{IConsumer} after it was previously paused with L{MultiPartProducer.pauseProducing}.
Method test_startProducing L{MultiPartProducer.startProducing} starts writing bytes from the input file to the given L{IConsumer} and returns a L{Deferred} which fires when they have all been written.
Method test_stopProducing L{MultiPartProducer.stopProducing} stops the underlying L{IPullProducer} and the cooperative task responsible for calling C{resumeProducing} and closes the input file but does not cause the L{Deferred} returned by C{startProducing} to fire.
Method test_twoFields Make sure multiple fields are rendered properly.
Method test_unicodeAttachmentName Make sure unicode attachment names are supported.
Method test_unicodeString Make sure unicode string is passed properly
Method test_unknownLength If the L{MultiPartProducer} is constructed with a file-like object passed as a parameter without either a C{seek} or C{tell} method, its C{length} attribute is set to C{UNKNOWN_LENGTH}.
Method test_worksWithCgi Make sure the stuff we generated actually parsed by python cgi
Instance Variable cooperator Undocumented
Method _termination This method can be used as the C{terminationPredicateFactory} for a L{Cooperator}. It returns a predicate which immediately returns C{False}, indicating that no more work should be done this iteration...
Instance Variable _scheduled Undocumented
def getOutput(self, producer, with_producer=False): (source)

A convenience function to consume and return outpute.

def newLines(self, value): (source)

Undocumented

def setUp(self): (source)

Create a L{Cooperator} hooked up to an easily controlled, deterministic scheduler to use with L{MultiPartProducer}.

def test_defaultCooperator(self): (source)

If no L{Cooperator} instance is passed to L{MultiPartProducer}, the global cooperator is used.

def test_failedReadWhileProducing(self): (source)

If a read from the input file fails while producing bytes to the consumer, the L{Deferred} returned by L{MultiPartProducer.startProducing} fires with a L{Failure} wrapping that exception.

def test_failOnByteStrings(self): (source)

If byte string is passed as a param and we don't know the encoding, fail early to prevent corrupted form posts

def test_failOnUnknownParams(self): (source)

If byte string is passed as a param and we don't know the encoding, fail early to prevent corrupted form posts

def test_fieldsAndAttachment(self): (source)

Make sure multiple fields are rendered properly.

def test_inputClosedAtEOF(self): (source)

When L{MultiPartProducer} reaches end-of-file on the input file given to it, the input file is closed.

def test_interface(self): (source)

L{MultiPartProducer} instances provide L{IBodyProducer}.

def test_knownLengthOnFile(self): (source)

If the L{MultiPartProducer} is constructed with a file-like object with both C{seek} and C{tell} methods, its C{length} attribute is set to the size of the file as determined by those methods.

def test_missingAttachmentName(self): (source)

Make sure attachments without names are supported

def test_multipleFieldsAndAttachments(self): (source)

Make sure multiple fields, attachments etc are rendered properly.

def test_newLinesInParams(self): (source)

Make sure we generate proper format even with newlines in attachments

def test_pauseProducing(self): (source)

L{MultiPartProducer.pauseProducing} temporarily suspends writing bytes from the input file to the given L{IConsumer}.

def test_resumeProducing(self): (source)

L{MultoPartProducer.resumeProducing} re-commences writing bytes from the input file to the given L{IConsumer} after it was previously paused with L{MultiPartProducer.pauseProducing}.

def test_startProducing(self): (source)

L{MultiPartProducer.startProducing} starts writing bytes from the input file to the given L{IConsumer} and returns a L{Deferred} which fires when they have all been written.

def test_stopProducing(self): (source)

L{MultiPartProducer.stopProducing} stops the underlying L{IPullProducer} and the cooperative task responsible for calling C{resumeProducing} and closes the input file but does not cause the L{Deferred} returned by C{startProducing} to fire.

def test_twoFields(self): (source)

Make sure multiple fields are rendered properly.

def test_unicodeAttachmentName(self): (source)

Make sure unicode attachment names are supported.

def test_unicodeString(self): (source)

Make sure unicode string is passed properly

def test_unknownLength(self): (source)

If the L{MultiPartProducer} is constructed with a file-like object passed as a parameter without either a C{seek} or C{tell} method, its C{length} attribute is set to C{UNKNOWN_LENGTH}.

def test_worksWithCgi(self): (source)

Make sure the stuff we generated actually parsed by python cgi

cooperator = (source)

Undocumented

def _termination(self): (source)

This method can be used as the C{terminationPredicateFactory} for a L{Cooperator}. It returns a predicate which immediately returns C{False}, indicating that no more work should be done this iteration. This has the result of only allowing one iteration of a cooperative task to be run per L{Cooperator} iteration.

_scheduled: list = (source)

Undocumented