summaryrefslogtreecommitdiff
path: root/addons/mail/tests/test_mail_message.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-12-12 17:06:34 +0100
committerThibault Delavallée <tde@openerp.com>2012-12-12 17:06:34 +0100
commitf1ee7f1ad9fe4a9a92e2058862f2c149347df3cd (patch)
treed4a8b19865a6e3017d28266b01ae4297584c1d95 /addons/mail/tests/test_mail_message.py
parent179f525dc7be6199da6f089da519faa3683a5ea5 (diff)
[IMP] mail_message: added the right to reply to a message wes received even if we cannot see the related document.
bzr revid: tde@openerp.com-20121212160634-umbiq2erwijm2d20
Diffstat (limited to 'addons/mail/tests/test_mail_message.py')
-rw-r--r--addons/mail/tests/test_mail_message.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py
index 3030d6d0d3e..39bb99007ee 100644
--- a/addons/mail/tests/test_mail_message.py
+++ b/addons/mail/tests/test_mail_message.py
@@ -123,7 +123,8 @@ class test_mail_access_rights(TestMailBase):
user_bert_id, user_raoul_id = self.user_bert_id, self.user_raoul_id
# Prepare groups: Pigs (employee), Jobs (public)
- self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message')
+ pigs_msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message')
+ priv_msg_id = self.mail_group.message_post(cr, uid, self.group_priv_id, body='Message')
# prepare an attachment
attachment_id = self.ir_attachment.create(cr, uid, {'datas': 'My attachment'.encode('base64'), 'name': 'doc.txt', 'datas_fname': 'doc.txt'})
@@ -184,11 +185,20 @@ class test_mail_access_rights(TestMailBase):
# Do: Bert create a private message -> ko, no creation rights
self.assertRaises(except_orm, self.mail_message.create,
cr, user_bert_id, {'body': 'Test'})
+
# Do: Raoul creates a message on Jobs -> ok, write access to the related document
self.mail_message.create(cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_jobs_id, 'body': 'Test'})
# Do: Raoul creates a message on Priv -> ko, no write access to the related document
self.assertRaises(except_orm, self.mail_message.create,
cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_priv_id, 'body': 'Test'})
+ # Do: Raoul creates a private message -> ok
+ self.mail_message.create(cr, user_raoul_id, {'body': 'Test'})
+ # Do: Raoul creates a reply to a message on Priv -> ko
+ self.assertRaises(except_orm, self.mail_message.create,
+ cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_priv_id, 'body': 'Test', 'parent_id': priv_msg_id})
+ # Do: Raoul creates a reply to a message on Priv-> ok if has received parent
+ self.mail_notification.create(cr, uid, {'message_id': priv_msg_id, 'partner_id': self.partner_raoul_id})
+ self.mail_message.create(cr, user_raoul_id, {'model': 'mail.group', 'res_id': self.group_priv_id, 'body': 'Test', 'parent_id': priv_msg_id})
def test_20_message_set_star(self):
""" Tests for starring messages and its related access rights """
@@ -326,6 +336,11 @@ class test_mail_access_rights(TestMailBase):
self.mail_group.message_post,
cr, user_bert_id, self.group_jobs_id, body='I love Pigs')
+ # Do: Bert writes on its own profile, ko because no message create access
+ with self.assertRaises(except_orm):
+ self.res_users.message_post(cr, user_bert_id, user_bert_id, body='I love Bert')
+ self.res_partner.message_post(cr, user_bert_id, partner_bert_id, body='I love Bert')
+
# ----------------------------------------
# CASE2: Raoul, employee
# ----------------------------------------
@@ -350,3 +365,11 @@ class test_mail_access_rights(TestMailBase):
{'subject': 'Subject', 'body': 'Body text'},
{'default_composition_mode': 'reply', 'default_parent_id': pigs_msg_id})
mail_compose.send_mail(cr, user_raoul_id, [compose_id])
+
+ # Do: Raoul writes on its own profile, ok because follower of its partner
+ self.res_users.message_post(cr, user_raoul_id, user_raoul_id, body='I love Raoul')
+ self.res_partner.message_post(cr, user_raoul_id, partner_raoul_id, body='I love Raoul')
+ compose_id = mail_compose.create(cr, user_raoul_id,
+ {'subject': 'Subject', 'body': 'Body text', 'partner_ids': []},
+ {'default_composition_mode': 'comment', 'default_model': 'res.users', 'default_res_id': self.user_raoul_id})
+ mail_compose.send_mail(cr, user_raoul_id, [compose_id])