diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/test_mail/tests/test_invite.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/test_mail/tests/test_invite.py')
| -rw-r--r-- | addons/test_mail/tests/test_invite.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_invite.py b/addons/test_mail/tests/test_invite.py new file mode 100644 index 00000000..c4e91a86 --- /dev/null +++ b/addons/test_mail/tests/test_invite.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.test_mail.tests.common import TestMailCommon +from odoo.tools import mute_logger + + +class TestInvite(TestMailCommon): + + @mute_logger('odoo.addons.mail.models.mail_mail') + def test_invite_email(self): + test_record = self.env['mail.test.simple'].with_context(self._test_context).create({'name': 'Test', 'email_from': 'ignasse@example.com'}) + test_partner = self.env['res.partner'].with_context(self._test_context).create({ + 'name': 'Valid Lelitre', + 'email': 'valid.lelitre@agrolait.com'}) + + mail_invite = self.env['mail.wizard.invite'].with_context({ + 'default_res_model': 'mail.test.simple', + 'default_res_id': test_record.id + }).with_user(self.user_employee).create({ + 'partner_ids': [(4, test_partner.id), (4, self.user_admin.partner_id.id)], + 'send_mail': True}) + with self.mock_mail_gateway(): + mail_invite.add_followers() + + # check added followers and that emails were sent + self.assertEqual(test_record.message_partner_ids, + test_partner | self.user_admin.partner_id) + self.assertEqual(test_record.message_follower_ids.mapped('channel_id'), + self.env['mail.channel']) + self.assertSentEmail(self.partner_employee, [test_partner]) + self.assertSentEmail(self.partner_employee, [self.partner_admin]) + self.assertEqual(len(self._mails), 2) |
