def test_SMTPReceiver(): receiver = server.SMTPReceiver(port=9999) receiver.start() receiver.process_message('localhost', 'test@localhost', 'test@localhost', 'Fake body.') routing.Router.deliver.side_effect = raises_exception receiver.process_message('localhost', 'test@localhost', 'test@localhost', 'Fake body.') receiver.close()
def make_fake_settings(host, port): """ When running as a logging server we need a fake settings module to work with since the logging server can be run in any directory, so there may not be a config/settings.py file to import. """ logging.basicConfig(filename="logs/logger.log", level=logging.DEBUG) routing.Router.load(['lamson.handlers.log', 'lamson.handlers.queue']) settings = imp.new_module('settings') settings.receiver = server.SMTPReceiver(host, port) settings.relay = None logging.info("Logging mode enabled, will not send email to anyone, just log.") return settings
def test_receiver(): receiver = server.SMTPReceiver(host="localhost", port=8824) msg = test_mail_request() receiver.process_message(msg.Peer, msg.From, msg.To, str(msg))