From 1e53dd9adbdcbba19f2dc1c56c40fc2b9fbd54d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 26 Nov 2020 08:42:58 +0000 Subject: [PATCH] [FIX] test_mail: make tests reproducible and independent from bus state Some tests are currently dependent on bus state when computing number of notifications sent. For example install Crm then test_mail_full. Some tests crash as too much notifications are found in the bus. We therefore clean remaining bus notifications before running tests to ensure we check notifications during test itself. This make tests more easy to reproduce. Task ID-2390314 PR #62061 X-original-commit: 92ff1379b0492765fd0ba9863a9ce13fba7eeb4a --- addons/test_mail/tests/test_message_management.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/test_mail/tests/test_message_management.py b/addons/test_mail/tests/test_message_management.py index b2c437ce2db..289b36817a1 100644 --- a/addons/test_mail/tests/test_message_management.py +++ b/addons/test_mail/tests/test_message_management.py @@ -79,6 +79,7 @@ class TestMailResend(TestMailCommon): @mute_logger('odoo.addons.mail.models.mail_mail') def test_remove_mail_become_canceled(self): # two failure sent on bus, one for each mail + self._reset_bus() with self.mock_mail_gateway(), self.assertBus([(self.cr.dbname, 'res.partner', self.partner_admin.id)] * 2): message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype_xmlid='mail.mt_comment', message_type='notification') @@ -101,6 +102,7 @@ class TestMailResend(TestMailCommon): @mute_logger('odoo.addons.mail.models.mail_mail') def test_cancel_all(self): + self._reset_bus() with self.mock_mail_gateway(), self.assertBus([(self.cr.dbname, 'res.partner', self.partner_admin.id)] * 2): message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype_xmlid='mail.mt_comment', message_type='notification')