mirror of
https://github.com/bringout/oca-ocb-test.git
synced 2026-04-21 17:02:00 +02:00
19.0 vanilla
This commit is contained in:
parent
38c6088dcc
commit
d9452d2060
243 changed files with 30797 additions and 10815 deletions
|
|
@ -1,13 +1,13 @@
|
|||
# -*- 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.addons.mail.tests.common import MailCommon
|
||||
from odoo.tests import tagged
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
|
||||
@tagged('mail_followers')
|
||||
class TestInvite(TestMailCommon):
|
||||
class TestInvite(MailCommon):
|
||||
|
||||
@mute_logger('odoo.addons.mail.models.mail_mail')
|
||||
def test_invite_email(self):
|
||||
|
|
@ -16,18 +16,38 @@ class TestInvite(TestMailCommon):
|
|||
'name': 'Valid Lelitre',
|
||||
'email': 'valid.lelitre@agrolait.com'})
|
||||
|
||||
mail_invite = self.env['mail.wizard.invite'].with_context({
|
||||
mail_invite = self.env['mail.followers.edit'].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()
|
||||
'default_res_ids': [test_record.id],
|
||||
}).with_user(self.user_employee).create({'partner_ids': [(4, test_partner.id), (4, self.user_admin.partner_id.id)],
|
||||
'notify': True})
|
||||
with self.mock_mail_app(), self.mock_mail_gateway():
|
||||
mail_invite.edit_followers()
|
||||
|
||||
# check added followers and that emails were sent
|
||||
# Check added followers and that notifications are sent.
|
||||
# Admin notification preference is inbox so the notification must be of inbox type
|
||||
# while partner_employee must receive it by email.
|
||||
self.assertEqual(test_record.message_partner_ids,
|
||||
test_partner | self.user_admin.partner_id)
|
||||
self.assertEqual(len(self._new_msgs), 1)
|
||||
self.assertEqual(len(self._mails), 1)
|
||||
self.assertSentEmail(self.partner_employee, [test_partner])
|
||||
self.assertSentEmail(self.partner_employee, [self.partner_admin])
|
||||
self.assertEqual(len(self._mails), 2)
|
||||
self.assertNotSentEmail([self.partner_admin])
|
||||
self.assertNotified(
|
||||
self._new_msgs[0],
|
||||
[{'partner': self.partner_admin, 'type': 'inbox', 'is_read': False}]
|
||||
)
|
||||
|
||||
# Remove followers
|
||||
mail_remove = self.env['mail.followers.edit'].with_context({
|
||||
'default_res_model': 'mail.test.simple',
|
||||
'default_res_ids': [test_record.id],
|
||||
}).with_user(self.user_employee).create({
|
||||
"operation": "remove",
|
||||
'partner_ids': [(4, test_partner.id), (4, self.user_admin.partner_id.id)]})
|
||||
|
||||
with self.mock_mail_app(), self.mock_mail_gateway():
|
||||
mail_remove.edit_followers()
|
||||
|
||||
# Check removed followers and that notifications are sent.
|
||||
self.assertEqual(test_record.message_partner_ids, self.env["res.partner"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue