def test_LMTPReceiver_process_message(): receiver = server.LMTPReceiver(host="localhost", port=0) msg = test_mail_request() with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert response is None, response with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): router_mock.deliver.side_effect = Exception() response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert response is None, response with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): router_mock.deliver.side_effect = server.SMTPError(450, "Not found") response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert_equal(response, "450 Not found") # lmtpd's server is a subclass of smtpd's server, so we should support the same kwargs here with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg), mail_options=[], rcpt_options=[]) assert response is None, response
def test_LMTPReceiver_process_message(): receiver = server.LMTPReceiver(host="localhost", port=0) msg = test_mail_request() with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert response is None, response with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): router_mock.deliver.side_effect = Exception() response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert response is None, response with patch("salmon.server.routing.Router") as router_mock, \ patch("salmon.server.undeliverable_message"): router_mock.deliver.side_effect = server.SMTPError(450, "Not found") response = receiver.process_message(msg.Peer, msg.From, msg.To, str(msg)) assert_equal(response, "450 Not found")
def test_LMTPreceiver(): receiver = server.LMTPReceiver(host="localhost", port=8894) msg = test_mail_request() receiver.process_message(msg.Peer, msg.From, msg.To, str(msg))