diff options
| author | Arnaud Pineux <api@openerp.com> | 2012-12-11 16:33:52 +0100 |
|---|---|---|
| committer | Arnaud Pineux <api@openerp.com> | 2012-12-11 16:33:52 +0100 |
| commit | d288b45bb3e192146dfd2fe40d840c8c23a79f74 (patch) | |
| tree | 55f0fed474aee380ecd2d6a544024763bd533a20 /addons/mail/tests | |
| parent | dd94a6b00a129c506299ec7e0b5739f5e9668a24 (diff) | |
| parent | c70f05cc778435a069d258a82b8b2870e8565922 (diff) | |
[MERGE] with trunk
bzr revid: api@openerp.com-20121211153352-l1ikpqgz8cxmuuu0
Diffstat (limited to 'addons/mail/tests')
| -rw-r--r-- | addons/mail/tests/test_mail.py | 4 | ||||
| -rw-r--r-- | addons/mail/tests/test_mail_access_rights.py | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index c18dea46452..6db6a8d6c71 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -421,6 +421,10 @@ class test_mail(test_mail_mockup.TestMailMockups): self.assertEqual(attach.res_id, self.group_pigs_id, 'mail.message attachment res_id incorrect') self.assertIn((attach.name, attach.datas.decode('base64')), _attachments, 'mail.message attachment name / data incorrect') + # Test: download attachments + for attach in message.attachment_ids: + dl_attach = self.mail_message.download_attachment(cr, uid, id_message=message.id, attachment_id=attach.id) + self.assertIn(( dl_attach['filename'], dl_attach['base64'].decode('base64') ), _attachments, 'mail.message download_attachment is incorrect') # 3. Reply to the last message, check that its parent will be the first message msg_id3 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Test', parent_id=msg_id2) diff --git a/addons/mail/tests/test_mail_access_rights.py b/addons/mail/tests/test_mail_access_rights.py index 1b2f7f85d71..15003ca9b87 100644 --- a/addons/mail/tests/test_mail_access_rights.py +++ b/addons/mail/tests/test_mail_access_rights.py @@ -31,6 +31,7 @@ class test_mail_access_rights(test_mail_mockup.TestMailMockups): cr, uid = self.cr, self.uid self.mail_group = self.registry('mail.group') self.mail_message = self.registry('mail.message') + self.attachment = self.registry('ir.attachment') self.mail_notification = self.registry('mail.notification') self.res_users = self.registry('res.users') self.res_groups = self.registry('res.groups') @@ -97,12 +98,16 @@ class test_mail_access_rights(test_mail_mockup.TestMailMockups): self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message') self.group_jobs_id = self.mail_group.create(cr, uid, {'name': 'Jobs', 'public': 'public'}) + # prepare an attachment + attachment_id = self.attachment.create(cr, uid, {'datas': 'My attachment'.encode('base64'), 'name': 'doc.txt', 'datas_fname': 'doc.txt' }) + # ---------------------------------------- # CASE1: Bert, basic mail.message read access # ---------------------------------------- # 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) @@ -110,11 +115,16 @@ class test_mail_access_rights(test_mail_mockup.TestMailMockups): 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 download 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 download 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 |
