changeset 7a2b34196f4f in modules/notification_email:default
details: 
https://hg.tryton.org/modules/notification_email?cmd=changeset;node=7a2b34196f4f
description:
        Run trigger in the queue

        This ensures that internal changes that are reverted later in the same
        transaction does not trigger an action.
        Also we ensure that a record is triggered by the same trigger only
        once per transaction.

        issue8342
        review280971002
diffstat:

 tests/test_notification_email.py |  11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diffs (35 lines):

diff -r 25026d83a708 -r 7a2b34196f4f tests/test_notification_email.py
--- a/tests/test_notification_email.py  Thu Mar 19 19:05:42 2020 +0100
+++ b/tests/test_notification_email.py  Sat Mar 28 17:13:12 2020 +0100
@@ -64,6 +64,15 @@
         notification_email.content = report
         notification_email.save()
 
+    def run_tasks(self):
+        pool = Pool()
+        Queue = pool.get('ir.queue')
+        transaction = Transaction()
+        self.assertTrue(transaction.tasks)
+        while transaction.tasks:
+            task = Queue(transaction.tasks.pop())
+            task.run()
+
     @unittest.skipIf(
         (3, 5, 0) <= sys.version_info < (3, 5, 2), "python bug #25195")
     @with_transaction()
@@ -99,6 +108,7 @@
                 notification_module, 'sendmail_transactional') as sendmail, \
                 patch.object(notification_module, 'SMTPDataManager'):
             User.create([{'name': "Michael Scott", 'login': "msc"}])
+            self.run_tasks()
             sendmail.assert_called_once_with(
                 FROM, ['[email protected]'], ANY,
                 datamanager=ANY)
@@ -212,6 +222,7 @@
                 notification_module, 'sendmail_transactional') as sendmail, \
                 patch.object(notification_module, 'SMTPDataManager'):
             User.create([{'name': "Michael Scott", 'login': "msc"}])
+            self.run_tasks()
             sendmail.assert_called_once_with(
                 FROM, ['[email protected]'], ANY,
                 datamanager=ANY)

Reply via email to