Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_smtpd.SMTPDChannelTest Class Reference
Inheritance diagram for test.test_smtpd.SMTPDChannelTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_smtpd.SMTPDChannelTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def write_line
def test_broken_connect
def test_server_accept
def test_missing_data
def test_EHLO_not_implemented
def test_HELO
def test_HELO_bad_syntax
def test_HELO_duplicate
def test_NOOP
def test_NOOP_bad_syntax
def test_QUIT
def test_QUIT_arg_ignored
def test_bad_state
def test_command_too_long
def test_data_too_long
def test_need_MAIL
def test_MAIL_syntax
def test_MAIL_missing_from
def test_MAIL_chevrons
def test_nested_MAIL
def test_need_RCPT
def test_RCPT_syntax
def test_data_dialog
def test_DATA_syntax
def test_data_transparency_section_4_5_2
def test_multiple_RCPT
def test_manual_status
def test_RSET
def test_RSET_syntax
def test_attribute_deprecations

Public Attributes

 debug
 server
 channel

Detailed Description

Definition at line 52 of file test_smtpd.py.


Member Function Documentation

Definition at line 53 of file test_smtpd.py.

00053 
00054     def setUp(self):
00055         smtpd.socket = asyncore.socket = mock_socket
00056         self.debug = smtpd.DEBUGSTREAM = io.StringIO()
00057         self.server = DummyServer('a', 'b')
00058         conn, addr = self.server.accept()
00059         self.channel = smtpd.SMTPChannel(self.server, conn, addr)

Here is the caller graph for this function:

Definition at line 60 of file test_smtpd.py.

00060 
00061     def tearDown(self):
00062         asyncore.close_all()
00063         asyncore.socket = smtpd.socket = socket

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 239 of file test_smtpd.py.

00239 
00240     def test_attribute_deprecations(self):
00241         with support.check_warnings(('', PendingDeprecationWarning)):
00242             spam = self.channel._SMTPChannel__server
00243         with support.check_warnings(('', PendingDeprecationWarning)):
00244             self.channel._SMTPChannel__server = 'spam'
00245         with support.check_warnings(('', PendingDeprecationWarning)):
00246             spam = self.channel._SMTPChannel__line
00247         with support.check_warnings(('', PendingDeprecationWarning)):
00248             self.channel._SMTPChannel__line = 'spam'
00249         with support.check_warnings(('', PendingDeprecationWarning)):
00250             spam = self.channel._SMTPChannel__state
00251         with support.check_warnings(('', PendingDeprecationWarning)):
00252             self.channel._SMTPChannel__state = 'spam'
00253         with support.check_warnings(('', PendingDeprecationWarning)):
00254             spam = self.channel._SMTPChannel__greeting
00255         with support.check_warnings(('', PendingDeprecationWarning)):
00256             self.channel._SMTPChannel__greeting = 'spam'
00257         with support.check_warnings(('', PendingDeprecationWarning)):
00258             spam = self.channel._SMTPChannel__mailfrom
00259         with support.check_warnings(('', PendingDeprecationWarning)):
00260             self.channel._SMTPChannel__mailfrom = 'spam'
00261         with support.check_warnings(('', PendingDeprecationWarning)):
00262             spam = self.channel._SMTPChannel__rcpttos
00263         with support.check_warnings(('', PendingDeprecationWarning)):
00264             self.channel._SMTPChannel__rcpttos = 'spam'
00265         with support.check_warnings(('', PendingDeprecationWarning)):
00266             spam = self.channel._SMTPChannel__data
00267         with support.check_warnings(('', PendingDeprecationWarning)):
00268             self.channel._SMTPChannel__data = 'spam'
00269         with support.check_warnings(('', PendingDeprecationWarning)):
00270             spam = self.channel._SMTPChannel__fqdn
00271         with support.check_warnings(('', PendingDeprecationWarning)):
00272             self.channel._SMTPChannel__fqdn = 'spam'
00273         with support.check_warnings(('', PendingDeprecationWarning)):
00274             spam = self.channel._SMTPChannel__peer
00275         with support.check_warnings(('', PendingDeprecationWarning)):
00276             self.channel._SMTPChannel__peer = 'spam'
00277         with support.check_warnings(('', PendingDeprecationWarning)):
00278             spam = self.channel._SMTPChannel__conn
00279         with support.check_warnings(('', PendingDeprecationWarning)):
00280             self.channel._SMTPChannel__conn = 'spam'
00281         with support.check_warnings(('', PendingDeprecationWarning)):
00282             spam = self.channel._SMTPChannel__addr
00283         with support.check_warnings(('', PendingDeprecationWarning)):
00284             self.channel._SMTPChannel__addr = 'spam'

Definition at line 118 of file test_smtpd.py.

00118 
00119     def test_bad_state(self):
00120         self.channel.smtp_state = 'BAD STATE'
00121         self.write_line(b'HELO')
00122         self.assertEqual(self.channel.socket.last,
00123                          b'451 Internal confusion\r\n')

Here is the call graph for this function:

Definition at line 68 of file test_smtpd.py.

00068 
00069     def test_broken_connect(self):
00070         self.assertRaises(DummyDispatcherBroken, BrokenDummyServer, 'a', 'b')

Here is the call graph for this function:

Definition at line 124 of file test_smtpd.py.

00124 
00125     def test_command_too_long(self):
00126         self.write_line(b'MAIL from ' +
00127                         b'a' * self.channel.command_size_limit +
00128                         b'@example')
00129         self.assertEqual(self.channel.socket.last,
00130                          b'500 Error: line too long\r\n')

Here is the call graph for this function:

Definition at line 179 of file test_smtpd.py.

00179 
00180     def test_data_dialog(self):
00181         self.write_line(b'MAIL From:eggs@example')
00182         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
00183         self.write_line(b'RCPT To:spam@example')
00184         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
00185 
00186         self.write_line(b'DATA')
00187         self.assertEqual(self.channel.socket.last,
00188             b'354 End data with <CR><LF>.<CR><LF>\r\n')
00189         self.write_line(b'data\r\nmore\r\n.')
00190         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
00191         self.assertEqual(self.server.messages,
00192             [('peer', 'eggs@example', ['spam@example'], 'data\nmore')])

Here is the call graph for this function:

Definition at line 193 of file test_smtpd.py.

00193 
00194     def test_DATA_syntax(self):
00195         self.write_line(b'MAIL From:eggs@example')
00196         self.write_line(b'RCPT To:spam@example')
00197         self.write_line(b'DATA spam')
00198         self.assertEqual(self.channel.socket.last, b'501 Syntax: DATA\r\n')

Here is the call graph for this function:

Definition at line 131 of file test_smtpd.py.

00131 
00132     def test_data_too_long(self):
00133         # Small hack. Setting limit to 2K octets here will save us some time.
00134         self.channel.data_size_limit = 2048
00135         self.write_line(b'MAIL From:eggs@example')
00136         self.write_line(b'RCPT To:spam@example')
00137         self.write_line(b'DATA')
00138         self.write_line(b'A' * self.channel.data_size_limit +
00139                         b'A\r\n.')
00140         self.assertEqual(self.channel.socket.last,
00141                          b'552 Error: Too much mail data\r\n')

Here is the call graph for this function:

Definition at line 199 of file test_smtpd.py.

00199 
00200     def test_data_transparency_section_4_5_2(self):
00201         self.write_line(b'MAIL From:eggs@example')
00202         self.write_line(b'RCPT To:spam@example')
00203         self.write_line(b'DATA')
00204         self.write_line(b'..\r\n.\r\n')
00205         self.assertEqual(self.channel.received_data, '.')

Here is the call graph for this function:

Definition at line 79 of file test_smtpd.py.

00079 
00080     def test_EHLO_not_implemented(self):
00081         self.write_line(b'EHLO test.example')
00082         self.assertEqual(self.channel.socket.last,
00083                          b'502 Error: command "EHLO" not implemented\r\n')

Here is the call graph for this function:

Definition at line 84 of file test_smtpd.py.

00084 
00085     def test_HELO(self):
00086         name = smtpd.socket.getfqdn()
00087         self.write_line(b'HELO test.example')
00088         self.assertEqual(self.channel.socket.last,
00089                          '250 {}\r\n'.format(name).encode('ascii'))

Here is the call graph for this function:

Definition at line 90 of file test_smtpd.py.

00090 
00091     def test_HELO_bad_syntax(self):
00092         self.write_line(b'HELO')
00093         self.assertEqual(self.channel.socket.last,
00094                          b'501 Syntax: HELO hostname\r\n')

Here is the call graph for this function:

Definition at line 95 of file test_smtpd.py.

00095 
00096     def test_HELO_duplicate(self):
00097         self.write_line(b'HELO test.example')
00098         self.write_line(b'HELO test.example')
00099         self.assertEqual(self.channel.socket.last,
00100                          b'503 Duplicate HELO/EHLO\r\n')

Here is the call graph for this function:

Definition at line 157 of file test_smtpd.py.

00157 
00158     def test_MAIL_chevrons(self):
00159         self.write_line(b'MAIL from:<eggs@example>')
00160         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')

Here is the call graph for this function:

Definition at line 152 of file test_smtpd.py.

00152 
00153     def test_MAIL_missing_from(self):
00154         self.write_line(b'MAIL from:')
00155         self.assertEqual(self.channel.socket.last,
00156             b'501 Syntax: MAIL FROM:<address>\r\n')

Here is the call graph for this function:

Definition at line 147 of file test_smtpd.py.

00147 
00148     def test_MAIL_syntax(self):
00149         self.write_line(b'MAIL from eggs@example')
00150         self.assertEqual(self.channel.socket.last,
00151             b'501 Syntax: MAIL FROM:<address>\r\n')

Here is the call graph for this function:

Definition at line 215 of file test_smtpd.py.

00215 
00216     def test_manual_status(self):
00217         # checks that the Channel is able to return a custom status message
00218         self.write_line(b'MAIL From:eggs@example')
00219         self.write_line(b'RCPT To:spam@example')
00220         self.write_line(b'DATA')
00221         self.write_line(b'return status\r\n.')
00222         self.assertEqual(self.channel.socket.last, b'250 Okish\r\n')

Here is the call graph for this function:

Definition at line 74 of file test_smtpd.py.

00074 
00075     def test_missing_data(self):
00076         self.write_line(b'')
00077         self.assertEqual(self.channel.socket.last,
00078                          b'500 Error: bad syntax\r\n')

Here is the call graph for this function:

Definition at line 206 of file test_smtpd.py.

00206 
00207     def test_multiple_RCPT(self):
00208         self.write_line(b'MAIL From:eggs@example')
00209         self.write_line(b'RCPT To:spam@example')
00210         self.write_line(b'RCPT To:ham@example')
00211         self.write_line(b'DATA')
00212         self.write_line(b'data\r\n.')
00213         self.assertEqual(self.server.messages,
00214             [('peer', 'eggs@example', ['spam@example','ham@example'], 'data')])

Here is the call graph for this function:

Definition at line 142 of file test_smtpd.py.

00142 
00143     def test_need_MAIL(self):
00144         self.write_line(b'RCPT to:spam@example')
00145         self.assertEqual(self.channel.socket.last,
00146             b'503 Error: need MAIL command\r\n')

Here is the call graph for this function:

Definition at line 167 of file test_smtpd.py.

00167 
00168     def test_need_RCPT(self):
00169         self.write_line(b'MAIL From:eggs@example')
00170         self.write_line(b'DATA')
00171         self.assertEqual(self.channel.socket.last,
00172             b'503 Error: need RCPT command\r\n')

Here is the call graph for this function:

Definition at line 161 of file test_smtpd.py.

00161 
00162     def test_nested_MAIL(self):
00163         self.write_line(b'MAIL from:eggs@example')
00164         self.write_line(b'MAIL from:spam@example')
00165         self.assertEqual(self.channel.socket.last,
00166             b'503 Error: nested MAIL command\r\n')

Here is the call graph for this function:

Definition at line 101 of file test_smtpd.py.

00101 
00102     def test_NOOP(self):
00103         self.write_line(b'NOOP')
00104         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')

Here is the call graph for this function:

Definition at line 105 of file test_smtpd.py.

00105 
00106     def test_NOOP_bad_syntax(self):
00107         self.write_line(b'NOOP hi')
00108         self.assertEqual(self.channel.socket.last,
00109                          b'501 Syntax: NOOP\r\n')

Here is the call graph for this function:

Definition at line 110 of file test_smtpd.py.

00110 
00111     def test_QUIT(self):
00112         self.write_line(b'QUIT')
00113         self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')

Here is the call graph for this function:

Definition at line 114 of file test_smtpd.py.

00114 
00115     def test_QUIT_arg_ignored(self):
00116         self.write_line(b'QUIT bye bye')
00117         self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')

Here is the call graph for this function:

Definition at line 173 of file test_smtpd.py.

00173 
00174     def test_RCPT_syntax(self):
00175         self.write_line(b'MAIL From:eggs@example')
00176         self.write_line(b'RCPT to eggs@example')
00177         self.assertEqual(self.channel.socket.last,
00178             b'501 Syntax: RCPT TO: <address>\r\n')

Here is the call graph for this function:

Definition at line 223 of file test_smtpd.py.

00223 
00224     def test_RSET(self):
00225         self.write_line(b'MAIL From:eggs@example')
00226         self.write_line(b'RCPT To:spam@example')
00227         self.write_line(b'RSET')
00228         self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
00229         self.write_line(b'MAIL From:foo@example')
00230         self.write_line(b'RCPT To:eggs@example')
00231         self.write_line(b'DATA')
00232         self.write_line(b'data\r\n.')
00233         self.assertEqual(self.server.messages,
00234             [('peer', 'foo@example', ['eggs@example'], 'data')])

Here is the call graph for this function:

Definition at line 235 of file test_smtpd.py.

00235 
00236     def test_RSET_syntax(self):
00237         self.write_line(b'RSET hi')
00238         self.assertEqual(self.channel.socket.last, b'501 Syntax: RSET\r\n')

Here is the call graph for this function:

Definition at line 71 of file test_smtpd.py.

00071 
00072     def test_server_accept(self):
00073         self.server.handle_accept()

def test.test_smtpd.SMTPDChannelTest.write_line (   self,
  line 
)

Definition at line 64 of file test_smtpd.py.

00064 
00065     def write_line(self, line):
00066         self.channel.socket.queue_recv(line)
00067         self.channel.handle_read()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 58 of file test_smtpd.py.

Definition at line 55 of file test_smtpd.py.

Definition at line 56 of file test_smtpd.py.


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