[FR] Add unit testing for emails (#3281)

Fixes #2232
This commit is contained in:
Matthias Mair 2022-07-03 12:38:26 +02:00 committed by GitHub
parent 9f5526f489
commit c81043ba42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
"""Tests for core_notifications."""
from django.core import mail
from part.test_part import BaseNotificationIntegrationTest
from plugin import registry
from plugin.builtin.integration.core_notifications import \
@ -12,6 +14,9 @@ class CoreNotificationTestTests(BaseNotificationIntegrationTest):
def test_email(self):
"""Ensure that the email notifications run."""
# No email should be send
self.assertEqual(len(mail.outbox), 0)
# enable plugin and set mail setting to true
plugin = registry.plugins.get('corenotificationsplugin')
plugin.set_setting('ENABLE_NOTIFICATION_EMAILS', True)
@ -25,3 +30,6 @@ class CoreNotificationTestTests(BaseNotificationIntegrationTest):
# run through
self._notification_run(CoreNotificationsPlugin.EmailNotification)
# Now one mail should be send
self.assertEqual(len(mail.outbox), 1)