summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_followers.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/test_mail/tests/test_mail_followers.py')
-rw-r--r--addons/test_mail/tests/test_mail_followers.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/addons/test_mail/tests/test_mail_followers.py b/addons/test_mail/tests/test_mail_followers.py
index de827326d6b..739c210d3e3 100644
--- a/addons/test_mail/tests/test_mail_followers.py
+++ b/addons/test_mail/tests/test_mail_followers.py
@@ -3,10 +3,10 @@
from psycopg2 import IntegrityError
-from odoo.tests import tagged, users
from odoo.addons.test_mail.tests.common import TestMailCommon
-from odoo.tools.misc import mute_logger
from odoo.tests import tagged
+from odoo.tests import users
+from odoo.tools.misc import mute_logger
@tagged('mail_followers')
@@ -101,6 +101,7 @@ class BaseFollowersTest(TestMailCommon):
self.assertEqual(test_record.message_follower_ids.subtype_ids, self.mt_mg_nodef | self.mt_al_nodef)
def test_followers_multiple_subscription_noforce(self):
+ """ Calling message_subscribe without subtypes on an existing subscription should not do anything (default < existing) """
test_record = self.test_record.with_user(self.user_employee)
test_record.message_subscribe(partner_ids=[self.user_admin.partner_id.id], subtype_ids=[self.mt_mg_nodef.id, self.mt_al_nodef.id])
@@ -114,6 +115,22 @@ class BaseFollowersTest(TestMailCommon):
self.assertEqual(test_record.message_channel_ids, self.env['mail.channel'])
self.assertEqual(test_record.message_follower_ids.subtype_ids, self.mt_mg_nodef | self.mt_al_nodef)
+ def test_followers_multiple_subscription_update(self):
+ """ Calling message_subscribe with subtypes on an existing subscription should replace them (new > existing) """
+ test_record = self.test_record.with_user(self.user_employee)
+ test_record.message_subscribe(partner_ids=[self.user_employee.partner_id.id], subtype_ids=[self.mt_mg_def.id, self.mt_cl_def.id])
+ self.assertEqual(test_record.message_partner_ids, self.user_employee.partner_id)
+ follower = self.env['mail.followers'].search([
+ ('res_model', '=', 'mail.test.simple'),
+ ('res_id', '=', test_record.id),
+ ('partner_id', '=', self.user_employee.partner_id.id)])
+ self.assertEqual(follower, test_record.message_follower_ids)
+ self.assertEqual(follower.subtype_ids, self.mt_mg_def | self.mt_cl_def)
+
+ # remove one subtype `mt_mg_def` and set new subtype `mt_al_def`
+ test_record.message_subscribe(partner_ids=[self.user_employee.partner_id.id], subtype_ids=[self.mt_cl_def.id, self.mt_al_def.id])
+ self.assertEqual(follower.subtype_ids, self.mt_cl_def | self.mt_al_def)
+
def test_followers_no_DID(self):
"""Test that a follower cannot suffer from dissociative identity disorder.
It cannot be both a partner and a channel.