Example #1
0
 def test_sendNonFatalError(self):
     """
     If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
     which is not fatal, it sends C{"QUIT"} and waits for the server to
     close the connection.
     """
     client = smtp.SMTPClient(None)
     transport = StringTransport()
     client.makeConnection(transport)
     client.sendError(smtp.SMTPClientError(123, "foo", isFatal=False))
     self.assertEqual(transport.value(), "QUIT\r\n")
     self.assertFalse(transport.disconnecting)
Example #2
0
 def test_sendOtherError(self):
     """
     If L{smtp.SMTPClient.sendError} is called with an exception which is
     not an L{SMTPClientError}, it disconnects its transport without
     writing anything more to it.
     """
     client = smtp.SMTPClient(None)
     transport = StringTransport()
     client.makeConnection(transport)
     client.sendError(Exception("foo"))
     self.assertEqual(transport.value(), "")
     self.assertTrue(transport.disconnecting)
Example #3
0
 def test_sendFatalError(self):
     """
     If L{smtp.SMTPClient.sendError} is called with an L{SMTPClientError}
     which is fatal, it disconnects its transport without writing anything
     more to it.
     """
     client = smtp.SMTPClient(None)
     transport = StringTransport()
     client.makeConnection(transport)
     client.sendError(smtp.SMTPClientError(123, "foo", isFatal=True))
     self.assertEqual(transport.value(), "")
     self.assertTrue(transport.disconnecting)