diff options
| author | Thibault Delavallée <tde@openerp.com> | 2012-12-11 17:14:58 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2012-12-11 17:14:58 +0100 |
| commit | b541e7ce6477e2567eecbaa96a8cfeca02d3868d (patch) | |
| tree | 6168c91acf958998eed50b88a937f32bc4146f7b /addons/mail/tests/test_mail_message.py | |
| parent | 023783324077937517a8fab476a3a5dbee5ed535 (diff) | |
| parent | 09030aa8d4c87d02e101af91e276ebeaacd43e91 (diff) | |
[MERGE] Sync with trunk. Cleaned a bit things lastly added in trunk/mail/tests.
bzr revid: tde@openerp.com-20121211161458-d7wv4lnkvs9s7srj
Diffstat (limited to 'addons/mail/tests/test_mail_message.py')
| -rw-r--r-- | addons/mail/tests/test_mail_message.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py index b93fd27bbed..c544cce8509 100644 --- a/addons/mail/tests/test_mail_message.py +++ b/addons/mail/tests/test_mail_message.py @@ -128,12 +128,16 @@ class test_mail_access_rights(TestMailBase): # Prepare groups: Pigs (employee), Jobs (public) self.mail_group.message_post(cr, uid, self.group_pigs_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'}) + # ---------------------------------------- # CASE1: read # ---------------------------------------- # Do: create a new mail.message - message_id = self.mail_message.create(cr, uid, {'body': 'My Body'}) + message_id = self.mail_message.create(cr, uid, {'body': 'My Body', 'attachment_ids': [(4, attachment_id)]}) + # Test: Bert reads the message, crash because not notification/not in doc followers/not read on doc self.assertRaises(except_orm, self.mail_message.read, cr, user_bert_id, message_id) @@ -141,11 +145,16 @@ class test_mail_access_rights(TestMailBase): notif_id = self.mail_notification.create(cr, uid, {'message_id': message_id, 'partner_id': partner_bert_id}) # Test: Bert reads the message, ok because notification pushed self.mail_message.read(cr, user_bert_id, message_id) + # Test: Bert downloads attachment, ok because he can read message + self.mail_message.download_attachment(cr, user_bert_id, message_id, attachment_id) # Do: remove notification self.mail_notification.unlink(cr, uid, notif_id) # Test: Bert reads the message, crash because not notification/not in doc followers/not read on doc self.assertRaises(except_orm, self.mail_message.read, cr, self.user_bert_id, message_id) + # Test: Bert downloads attachment, crash because he can't read message + self.assertRaises(except_orm, self.mail_message.download_attachment, + cr, user_bert_id, message_id, attachment_id) # Do: Bert is now the author self.mail_message.write(cr, uid, [message_id], {'author_id': partner_bert_id}) # Test: Bert reads the message, ok because Bert is the author |
