def test_setting_is_false(self, mock_config): """ Tests the emails_enabled function when the Constance config is False. """ mock_config.EMAIL_NOTIFICATIONS_ENABLED = False self.assertFalse(emails_enabled())
def test_setting_does_not_exist(self, mock_config): """ Tests the emails_enabled function when the Constance config doesn't exist. """ del mock_config.EMAIL_NOTIFICATIONS_ENABLED self.assertEqual(emails_enabled(), True)
def send_comment_notification(sender, instance, created, **kwargs): """Email relevant users when a new |Comment| is saved.""" # email relevant users if a comment is created if created and emails_enabled(): for user in instance.get_other_contributors(): email_message = compose_comment_email(instance, user) try: email_message.send() except smtplib.SMTPAuthenticationError as error: _LOGGER.error( 'An error occurred when sending an ' 'email notification: %s', error)