changeset 87c62dd58c1a in modules/notification_email:default
details:
https://hg.tryton.org/modules/notification_email?cmd=changeset;node=87c62dd58c1a
description:
Add test for email notification with no recipients
issue9485
review303961002
diffstat:
tests/test_notification_email.py | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diffs (44 lines):
diff -r 607fcb08ec74 -r 87c62dd58c1a tests/test_notification_email.py
--- a/tests/test_notification_email.py Mon Jul 27 16:16:17 2020 +0200
+++ b/tests/test_notification_email.py Mon Jul 27 16:16:33 2020 +0200
@@ -277,6 +277,40 @@
_, _, msg = sendmail.call_args[0]
self.assertEqual(msg['To'], 'Fallback <[email protected]>')
+ @with_transaction()
+ def test_notification_email_no_recipient(self):
+ "Test email notification no recipient"
+ pool = Pool()
+ User = pool.get('res.user')
+ Trigger = pool.get('ir.trigger')
+ Model = pool.get('ir.model')
+ NotificationEmail = pool.get('notification.email')
+ User = pool.get('res.user')
+
+ self._setup_notification()
+ notification_email, = NotificationEmail.search([])
+ notification_email.recipients = None
+ notification_email.save()
+
+ model, = Model.search([
+ ('model', '=', User.__name__),
+ ])
+ Trigger.create([{
+ 'name': 'Test creation',
+ 'model': model.id,
+ 'on_create': True,
+ 'condition': 'true',
+ 'notification_email': notification_email.id,
+ 'action': 'notification.email|trigger',
+ }])
+
+ with patch.object(
+ notification_module, 'get_email') as get_email, \
+ patch.object(notification_module, 'SMTPDataManager'):
+ User.create([{'name': "Michael Scott", 'login': "msc"}])
+ self.run_tasks()
+ get_email.assert_not_called()
+
def suite():
suite = test_suite()