\doxysection{Milter.\+test.\+Test\+Base Class Reference}
\label{classMilter_1_1test_1_1TestBase}\index{Milter.test.TestBase@{Milter.test.TestBase}}


Test mixin for unit testing milter applications.  


Inheritance diagram for Milter.\+test.\+Test\+Base\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classMilter_1_1test_1_1TestBase}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\label{classMilter_1_1test_1_1TestBase_a946d4ce73229638bc503c66041a7af5e} 
{\bfseries \+\_\+\+\_\+init\+\_\+\+\_\+} (self, logfile=\textquotesingle{}\textbf{ test}/milter.\+log\textquotesingle{})
\item 
\label{classMilter_1_1test_1_1TestBase_a3fcea10927e3d0d91ccff0f63e641bbd} 
{\bfseries log} (self, $\ast$msg)
\item 
\textbf{ setsymval} (self, name, val)
\begin{DoxyCompactList}\small\item\em Set a macro value. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a3fa3db328c077678d1b89b5d3350d752} 
{\bfseries getsymval} (self, name)
\item 
\label{classMilter_1_1test_1_1TestBase_abc8dd6b1aba6b2d441726f3a8b0c7a0f} 
{\bfseries replacebody} (self, chunk)
\item 
\label{classMilter_1_1test_1_1TestBase_a21e78957f5dcdbde2721aa8488a6fe7e} 
{\bfseries chgfrom} (self, sender, params=None)
\item 
\label{classMilter_1_1test_1_1TestBase_ac459835e1f5a7103accb7379836aaf76} 
{\bfseries quarantine} (self, reason)
\item 
\label{classMilter_1_1test_1_1TestBase_a3da500f02c06e443a0d6c998e4a8df16} 
{\bfseries progress} (self)
\item 
\label{classMilter_1_1test_1_1TestBase_adc6913c27c233c97ca9ea0519770b477} 
{\bfseries chgheader} (self, field, idx, value)
\item 
\label{classMilter_1_1test_1_1TestBase_a32dd6da74800d279b9eaacf2d393af76} 
{\bfseries addheader} (self, field, value, idx=-\/1)
\item 
\label{classMilter_1_1test_1_1TestBase_adfe6d7ca803d2de0bf5c652308d65ae3} 
{\bfseries delrcpt} (self, rcpt)
\item 
\label{classMilter_1_1test_1_1TestBase_ab192a5eca7596a864aa699cc01974dba} 
{\bfseries addrcpt} (self, rcpt)
\item 
\label{classMilter_1_1test_1_1TestBase_a26b736cfb943c90184615864b7ccbd65} 
{\bfseries setreply} (self, rcode, xcode, $\ast$msg)
\begin{DoxyCompactList}\small\item\em Save the reply codes and messages in self.\+\_\+reply. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_af7d3bce3655d1a8070e9147698e61e28} 
{\bfseries setsymlist} (self, stage, macros)
\item 
\textbf{ feed\+File} (self, fp, sender="{}spam@adv.\+com"{}, rcpt="{}victim@lamb.\+com"{}, $\ast$rcpts)
\begin{DoxyCompactList}\small\item\em Feed a file like object to the milter. \end{DoxyCompactList}\item 
\textbf{ feed\+Msg} (self, fname, sender="{}spam@adv.\+com"{}, $\ast$rcpts)
\begin{DoxyCompactList}\small\item\em Feed an email contained in a file to the milter. \end{DoxyCompactList}\item 
\textbf{ connect} (self, host=\textquotesingle{}localhost\textquotesingle{}, helo=\textquotesingle{}spamrelay\textquotesingle{}, ip=\textquotesingle{}1.\+2.\+3.\+4\textquotesingle{})
\begin{DoxyCompactList}\small\item\em Call the connect and helo callbacks. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\label{classMilter_1_1test_1_1TestBase_ae576a5c9292c902cacf776706b51ee83} 
{\bfseries logfp} = open(logfile,"{}a"{})
\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\label{classMilter_1_1test_1_1TestBase_add58719ccfc8d1513629e7c0e36c9ee5} 
{\bfseries \+\_\+close} (self)
\end{DoxyCompactItemize}
\doxysubsubsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\label{classMilter_1_1test_1_1TestBase_a0fc6352f77492f89c2edff0be7f66d2f} 
int {\bfseries \+\_\+protocol} = 0
\item 
\label{classMilter_1_1test_1_1TestBase_a8d035d57d134dd480704f4af0be4da55} 
str {\bfseries \+\_\+sender} = None
\begin{DoxyCompactList}\small\item\em The MAIL FROM for the current email being fed to the milter. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_adaa12827a3b3700078b115cfcabb5c8d} 
list {\bfseries \+\_\+delrcpt} = [$\,$]
\begin{DoxyCompactList}\small\item\em List of recipients deleted. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_aab2f7ba40a3bfabb661010a5bfaaa34b} 
list {\bfseries \+\_\+addrcpt} = [$\,$]
\begin{DoxyCompactList}\small\item\em List of recipients added. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a840e89946277611d42b8749189ff7619} 
dict {\bfseries \+\_\+macros} = \{ \}
\begin{DoxyCompactList}\small\item\em Macros defined. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a91f2c2958adb1b070219caed7a4a3bec} 
{\bfseries \+\_\+body} = None
\begin{DoxyCompactList}\small\item\em The message body. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_ad51a3475b77582f88d5d52169b21dd32} 
bool {\bfseries \+\_\+bodyreplaced} = False
\begin{DoxyCompactList}\small\item\em True if the milter replaced the message body. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a94a1150dd2192a6d7739d14988bb51c2} 
bool {\bfseries \+\_\+headerschanged} = False
\begin{DoxyCompactList}\small\item\em True if the milter changed any headers. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_ac379b9617376502e3a09a81b2dadf732} 
bool {\bfseries \+\_\+envfromchanged} = False
\begin{DoxyCompactList}\small\item\em True if the milter changed the envelope from. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a7d4394f155146b311b84878aa6e10e90} 
tuple {\bfseries \+\_\+reply} = None
\begin{DoxyCompactList}\small\item\em Reply codes and messages set by the milter. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a197497e481c38a59a313a55d8dc6f280} 
{\bfseries \+\_\+msg} = None
\begin{DoxyCompactList}\small\item\em The rfc822 message object for the current email being fed to the milter. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_a89c46532de62598a90411fd70f6a02c4} 
int {\bfseries \+\_\+stage} = None
\begin{DoxyCompactList}\small\item\em The protocol stage for macros returned. \end{DoxyCompactList}\item 
\label{classMilter_1_1test_1_1TestBase_aedabb367e03e1b7ebcffef8c6ff8e36e} 
list {\bfseries \+\_\+symlist} = [ None, None, None, None, None, None, None ]
\begin{DoxyCompactList}\small\item\em The macros returned by protocol stage. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Test mixin for unit testing milter applications. 

This mixin overrides many Milter.\+Milter\+Base methods with stub versions that simply record what was done. \begin{DoxyRefDesc}{Deprecated}
\item[\textbf{ Deprecated}]Use Milter.\+test.\+Test\+Ctx \end{DoxyRefDesc}
\begin{DoxySince}{Since}
0.\+9.\+8 
\end{DoxySince}


\label{doc-func-members}
\doxysubsection{Member Function Documentation}
\index{Milter.test.TestBase@{Milter.test.TestBase}!connect@{connect}}
\index{connect@{connect}!Milter.test.TestBase@{Milter.test.TestBase}}
\doxysubsubsection{connect()}
{\footnotesize\ttfamily \label{classMilter_1_1test_1_1TestBase_aac23431e6bc8ff54e92fca55a8914aa4} 
Milter.\+test.\+Test\+Base.\+connect (\begin{DoxyParamCaption}\item[{}]{self}{, }\item[{}]{host}{ = {\ttfamily \textquotesingle{}localhost\textquotesingle{}}, }\item[{}]{helo}{ = {\ttfamily \textquotesingle{}spamrelay\textquotesingle{}}, }\item[{}]{ip}{ = {\ttfamily \textquotesingle{}1.2.3.4\textquotesingle{}}}\end{DoxyParamCaption})}



Call the connect and helo callbacks. 

The helo callback is not called if connect does not return CONTINUE. 
\begin{DoxyParams}{Parameters}
{\em host} & the hostname passed to the connect callback \\
\hline
{\em helo} & the hostname passed to the helo callback \\
\hline
{\em ip} & the IP address passed to the connect callback \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+body}, \textbf{ \+\_\+bodyreplaced}, \textbf{ Milter.\+Base.\+\_\+setctx()}, \textbf{ \+\_\+stage}, \textbf{ Milter.\+Base.\+close()}, Milter.\+greylist.\+Greylist.\+close(), Milter.\+greysql.\+Greylist.\+close(), \textbf{ Milter.\+Milter.\+close()}, Milter.\+policy.\+DB.\+close(), Milter.\+policy.\+MTAPolicy.\+close(), \textbf{ Milter.\+sgmllib.\+SGMLParser.\+close()}, \textbf{ Milter.\+sgmllib.\+Test\+SGMLParser.\+close()}, \textbf{ connect()}, \textbf{ Milter.\+Base.\+hello()}, \textbf{ Milter.\+Milter.\+hello()}, and \textbf{ Milter.\+Base.\+negotiate()}.



Referenced by \textbf{ connect()}.

\index{Milter.test.TestBase@{Milter.test.TestBase}!feedFile@{feedFile}}
\index{feedFile@{feedFile}!Milter.test.TestBase@{Milter.test.TestBase}}
\doxysubsubsection{feedFile()}
{\footnotesize\ttfamily \label{classMilter_1_1test_1_1TestBase_ab8928a260a93a021668f9cbf70640526} 
Milter.\+test.\+Test\+Base.\+feed\+File (\begin{DoxyParamCaption}\item[{}]{self}{, }\item[{}]{fp}{, }\item[{}]{sender}{ = {\ttfamily "{}spam@adv.com"{}}, }\item[{}]{rcpt}{ = {\ttfamily "{}victim@lamb.com"{}}, }\item[{$\ast$}]{rcpts}{}\end{DoxyParamCaption})}



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. 
\begin{DoxyParams}{Parameters}
{\em fp} & the file with rfc2822 message stream \\
\hline
{\em sender} & the MAIL FROM \\
\hline
{\em rcpt} & RCPT TO -\/ additional recipients may follow \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+body}, \textbf{ \+\_\+bodyreplaced}, \+\_\+close(), \textbf{ \+\_\+headerschanged}, \textbf{ \+\_\+msg}, \textbf{ \+\_\+reply}, \textbf{ \+\_\+sender}, \textbf{ \+\_\+stage}, \textbf{ Milter.\+Base.\+body()}, \textbf{ Milter.\+Base.\+close()}, Milter.\+greylist.\+Greylist.\+close(), Milter.\+greysql.\+Greylist.\+close(), \textbf{ Milter.\+Milter.\+close()}, Milter.\+policy.\+DB.\+close(), Milter.\+policy.\+MTAPolicy.\+close(), \textbf{ Milter.\+sgmllib.\+SGMLParser.\+close()}, \textbf{ Milter.\+sgmllib.\+Test\+SGMLParser.\+close()}, \textbf{ Milter.\+Base.\+data()}, \textbf{ Milter.\+Base.\+envfrom()}, \textbf{ Milter.\+Milter.\+envfrom()}, \textbf{ Milter.\+Base.\+envrcpt()}, \textbf{ Milter.\+Milter.\+envrcpt()}, \textbf{ Milter.\+Base.\+eoh()}, \textbf{ Milter.\+Milter.\+eoh()}, \textbf{ Milter.\+Base.\+eom()}, \textbf{ Milter.\+Milter.\+eom()}, Milter.\+Base.\+header\+\_\+bytes, and \textbf{ Milter.\+Base.\+header\+\_\+bytes()}.



Referenced by \textbf{ feed\+Msg()}.

\index{Milter.test.TestBase@{Milter.test.TestBase}!feedMsg@{feedMsg}}
\index{feedMsg@{feedMsg}!Milter.test.TestBase@{Milter.test.TestBase}}
\doxysubsubsection{feedMsg()}
{\footnotesize\ttfamily \label{classMilter_1_1test_1_1TestBase_a6923a00079eb6114a2825c4ea47e1d13} 
Milter.\+test.\+Test\+Base.\+feed\+Msg (\begin{DoxyParamCaption}\item[{}]{self}{, }\item[{}]{fname}{, }\item[{}]{sender}{ = {\ttfamily "{}spam@adv.com"{}}, }\item[{$\ast$}]{rcpts}{}\end{DoxyParamCaption})}



Feed an email contained in a file to the milter. 

This is a convenience method that invokes \doxyref{feed\+File }{p.}{classMilter_1_1test_1_1TestBase_ab8928a260a93a021668f9cbf70640526}. 
\begin{DoxyParams}{Parameters}
{\em sender} & MAIL FROM \\
\hline
{\em rcpts} & RCPT TO, multiple recipients may be supplied \\
\hline
\end{DoxyParams}


References \textbf{ feed\+File()}.

\index{Milter.test.TestBase@{Milter.test.TestBase}!setsymval@{setsymval}}
\index{setsymval@{setsymval}!Milter.test.TestBase@{Milter.test.TestBase}}
\doxysubsubsection{setsymval()}
{\footnotesize\ttfamily \label{classMilter_1_1test_1_1TestBase_a15f2a8c7c08af2f29ef291ebc2f6ff5f} 
Milter.\+test.\+Test\+Base.\+setsymval (\begin{DoxyParamCaption}\item[{}]{self}{, }\item[{}]{name}{, }\item[{}]{val}{}\end{DoxyParamCaption})}



Set a macro value. 

These are retrieved by the milter with getsymval. 
\begin{DoxyParams}{Parameters}
{\em name} & the macro name, as passed to getsymval \\
\hline
{\em val} & the macro value \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+body}, \textbf{ \+\_\+bodyreplaced}, \textbf{ \+\_\+envfromchanged}, \textbf{ \+\_\+macros}, \textbf{ \+\_\+sender}, \textbf{ \+\_\+stage}, \textbf{ \+\_\+symlist}, \textbf{ Milter.\+Base.\+log()}, \textbf{ Milter.\+Milter.\+log()}, and log().



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
Milter/test.\+py\end{DoxyCompactItemize}
