pymilter  0.9.6
Public Member Functions | Public Attributes | Private Attributes | List of all members
Milter.test.TestBase Class Reference

Test mixin for unit testing milter applications. More...

Public Member Functions

def __init__
def log
def setsymval
 Set a macro value.
def getsymval
def replacebody
def chgheader
def addheader
def delrcpt
def addrcpt
def setreply
 Save the reply codes and messages in self._reply.
def setsymlist
def feedFile
 Feed a file like object to the milter.
def feedMsg
 Feed an email contained in a file to the milter.
def connect
 Call the connect and helo callbacks.

Public Attributes

 logfp

Private Attributes

 _protocol
 _delrcpt
 List of recipients deleted.
 _addrcpt
 List of recipients added.
 _macros
 Macros defined.
 _body
 The message body.
 _bodyreplaced
 True if the milter replaced the message body.
 _headerschanged
 True if the milter changed any headers.
 _reply
 Reply codes and messages set by milter.
 _msg
 The rfc822 message object for the current email being fed to the milter.
 _symlist

Detailed Description

Test mixin for unit testing milter applications.

This mixin overrides many Milter.MilterBase methods with stub versions that simply record what was done.

Since
0.9.8

Member Function Documentation

def Milter.test.TestBase.connect (   self,
  host = 'localhost',
  helo = 'spamrelay',
  ip = '1.2.3.4' 
)

Call the connect and helo callbacks.

The helo callback is not called if connect does not return CONTINUE.

Parameters
hostthe hostname passed to the connect callback
helothe hostname passed to the helo callback
ipthe IP address passed to the connect callback
def Milter.test.TestBase.feedFile (   self,
  fp,
  sender = "spam@adv.com",
  rcpt = "victim@lamb.com",
  rcpts 
)

Feed a file like object to the milter.

Calls envfrom, envrcpt for each recipient, header for each header field, body for each body block, and finally eom. A return code from the milter other than CONTINUE returns immediately with that return code.

This is a convenience method, a test could invoke the callbacks in sequence on its own - and for some complex tests, this may be necessary.

Parameters
fpthe file with rfc2822 message stream
senderthe MAIL FROM
rcptRCPT TO - additional recipients may follow
def Milter.test.TestBase.feedMsg (   self,
  fname,
  sender = "spam@adv.com",
  rcpts 
)

Feed an email contained in a file to the milter.

This is a convenience method that invokes feedFile .

Parameters
senderMAIL FROM
rcptsRCPT TO, multiple recipients may be supplied
def Milter.test.TestBase.setreply (   self,
  rcode,
  xcode,
  msg 
)

Save the reply codes and messages in self._reply.

def Milter.test.TestBase.setsymval (   self,
  name,
  val 
)

Set a macro value.

These are retrieved by the milter with getsymval.

Parameters
namethe macro name, as passed to getsymval
valthe macro value

Member Data Documentation

Milter.test.TestBase._body
private

The message body.

Milter.test.TestBase._bodyreplaced
private

True if the milter replaced the message body.

Milter.test.TestBase._headerschanged
private

True if the milter changed any headers.

Milter.test.TestBase._msg
private

The rfc822 message object for the current email being fed to the milter.


The documentation for this class was generated from the following file: