def test_smtp_send(self, mock_smtp): self.config.email.use_ssl = False sender = email_sender.get(self.config, 'SMTP') sender.send('*****@*****.**', 'Test!', 'foo bar.') mock_smtp.assert_called_once_with(SMTP_HOST) smtp = mock_smtp.return_value smtp.login.assert_called_once_with(SMTP_USER, SMTP_PASSWORD) msg = ('Content-Type: text/plain; charset="utf-8"\n' 'Content-Transfer-Encoding: 7bit\n' 'MIME-Version: 1.0\n' 'Subject: Test!\n\nfoo bar.\n') smtp.sendmail.assert_called_once_with(EMAIL_FROM, '*****@*****.**', msg)
def __init__(self, config, db, queue, tg_bot=None): self.config = config self.db = db self.queue = queue self.formatter = message_formatter.MessageFormatter() try: self.sms_sender = sms_sender.get(config) except Exception as e: logging.warning(f"Cannot set sms_sender {e}") self.sms_sender = None try: self.email_sender = email_sender.get(config) except Exception as e: logging.warning(f"Cannot set email_sender {e}") self.email_sender = None # This might return be None if telegram is not properly set. self.telegram_bot = integrator.TelegramSetup(config, db, tg_bot=tg_bot).bot
def test_fake_send(self): sender = email_sender.get(self.config, 'FAKE') sender.send('*****@*****.**', 'Test!', 'foo bar.')