mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add tests for email notification
This commit is contained in:
parent
e1d261f989
commit
b4654a7c71
@ -7,7 +7,7 @@ from allauth.account.models import EmailAddress
|
|||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import IntegrationPluginBase
|
||||||
from plugin.mixins import BulkNotificationMethod, SettingsMixin
|
from plugin.mixins import BulkNotificationMethod, SettingsMixin
|
||||||
from common.models import InvenTreeUserSetting
|
from plugin.models import NotificationUserSetting
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
|||||||
allowed_users = []
|
allowed_users = []
|
||||||
|
|
||||||
for user in self.targets:
|
for user in self.targets:
|
||||||
allows_emails = InvenTreeUserSetting.get_setting('NOTIFICATION_SEND_EMAILS', user=user)
|
allows_emails = NotificationUserSetting.get_setting('NOTIFICATION_METHOD_MAIL', user=user, method=self.METHOD_NAME)
|
||||||
|
|
||||||
if allows_emails:
|
if allows_emails:
|
||||||
allowed_users.append(user)
|
allowed_users.append(user)
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from allauth.account.models import EmailAddress
|
||||||
|
|
||||||
|
from plugin.models import NotificationUserSetting
|
||||||
|
from part.test_part import BaseNotificationIntegrationTest
|
||||||
|
from plugin.builtin.integration.core_notifications import CoreNotificationsPlugin
|
||||||
|
from plugin import registry
|
||||||
|
|
||||||
|
|
||||||
|
class CoreNotificationTestTests(BaseNotificationIntegrationTest):
|
||||||
|
|
||||||
|
def test_email(self):
|
||||||
|
"""
|
||||||
|
Ensure that the email notifications run
|
||||||
|
"""
|
||||||
|
|
||||||
|
# enable plugin and set mail setting to true
|
||||||
|
plugin = registry.plugins.get('corenotificationsplugin')
|
||||||
|
plugin.set_setting('ENABLE_NOTIFICATION_EMAILS', True)
|
||||||
|
NotificationUserSetting.set_setting(
|
||||||
|
key='NOTIFICATION_METHOD_MAIL',
|
||||||
|
value=True,
|
||||||
|
change_user=self.user,
|
||||||
|
user=self.user,
|
||||||
|
method=CoreNotificationsPlugin.EmailNotification.METHOD_NAME
|
||||||
|
)
|
||||||
|
|
||||||
|
# run through
|
||||||
|
self._notification_run(CoreNotificationsPlugin.EmailNotification)
|
Loading…
Reference in New Issue
Block a user