From c81043ba428fae2b6c4d66da48fe8c6ac9a21002 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sun, 3 Jul 2022 12:38:26 +0200 Subject: [PATCH] [FR] Add unit testing for emails (#3281) Fixes #2232 --- .../plugin/builtin/integration/test_core_notifications.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/plugin/builtin/integration/test_core_notifications.py b/InvenTree/plugin/builtin/integration/test_core_notifications.py index 1ff60c74b1..88c166bf78 100644 --- a/InvenTree/plugin/builtin/integration/test_core_notifications.py +++ b/InvenTree/plugin/builtin/integration/test_core_notifications.py @@ -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)