Files
odoo_source/addons/test_mail/tests/test_invite.py
T
Thibault Delavallée a7b3d1697c [REF] test_mail: use odoo test helper method to create test users
Purpose of this commit is to use the newly introduced helper to create
test users in a quick way and reduce code duplication. A mail specific
helper tool function is defined based on the standard one defined in test
allowing to pass a custom context. It bypasses mailing features in order
to speedup the creation.

This commit is linked to task ID 1889703 and PR #27526.
2018-10-18 13:57:02 +00:00

30 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests import common
from odoo.tools import mute_logger
class TestInvite(common.BaseFunctionalTest, common.MockEmails):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_invite_email(self):
test_partner = self.env['res.partner'].with_context(common.BaseFunctionalTest._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': self.test_record.id
}).sudo(self.user_employee.id).create({
'partner_ids': [(4, test_partner.id), (4, self.user_admin.partner_id.id)],
'send_mail': True})
mail_invite.add_followers()
# check added followers and that emails were sent
self.assertEqual(self.test_record.message_partner_ids,
test_partner | self.user_admin.partner_id)
self.assertEqual(self.test_record.message_follower_ids.mapped('channel_id'),
self.env['mail.channel'])
self.assertEqual(len(self._mails), 2)