diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 71bbda566df..0aa4377b77a 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -3,4 +3,4 @@ from . import models from . import wizard from . import controllers -from .tests import test_mail_model +from .tests import models diff --git a/addons/mail/tests/__init__.py b/addons/mail/tests/__init__.py index 5495e974899..52a9f75b9d3 100644 --- a/addons/mail/tests/__init__.py +++ b/addons/mail/tests/__init__.py @@ -2,13 +2,13 @@ from . import test_mail_followers from . import test_mail_message -from . import test_mail_features from . import test_mail_channel from . import test_mail_gateway +from . import test_mail_template +from . import test_message_compose from . import test_message_read from . import test_message_track -from . import test_mail_template from . import test_invite from . import test_ir_actions from . import test_update_notification -from . import test_portal +from . import test_discuss diff --git a/addons/mail/tests/data/__init__.py b/addons/mail/tests/data/__init__.py new file mode 100644 index 00000000000..3c2bb4e3324 --- /dev/null +++ b/addons/mail/tests/data/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_mail_data diff --git a/addons/mail/tests/data/test_mail_data.py b/addons/mail/tests/data/test_mail_data.py new file mode 100644 index 00000000000..e743b5ce544 --- /dev/null +++ b/addons/mail/tests/data/test_mail_data.py @@ -0,0 +1,280 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +MAIL_TEMPLATE = """Return-Path: +To: {to} +cc: {cc} +Received: by mail1.openerp.com (Postfix, from userid 10002) + id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST) +From: {email_from} +Subject: {subject} +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_4200734_24778174.1344608186754" +Date: Fri, 10 Aug 2012 14:16:26 +0000 +Message-ID: {msg_id} +{extra} +------=_Part_4200734_24778174.1344608186754 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + +Please call me as soon as possible this afternoon! + +-- +Sylvie +------=_Part_4200734_24778174.1344608186754 +Content-Type: text/html; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + + + + =20 + + =20 + =20 + +

Please call me as soon as possible this afternoon!

+ +

--
+ Sylvie +

+ + +------=_Part_4200734_24778174.1344608186754-- +""" + +MAIL_TEMPLATE_PLAINTEXT = """Return-Path: +To: {to} +Received: by mail1.openerp.com (Postfix, from userid 10002) + id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST) +From: Sylvie Lelitre +Subject: {subject} +MIME-Version: 1.0 +Content-Type: text/plain +Date: Fri, 10 Aug 2012 14:16:26 +0000 +Message-ID: {msg_id} +{extra} + +Please call me as soon as possible this afternoon! + +-- +Sylvie +""" + +MAIL_MULTIPART_MIXED = """Return-Path: +X-Original-To: raoul@grosbedon.fr +Delivered-To: raoul@grosbedon.fr +Received: by mail1.grosbedon.com (Postfix, from userid 10002) + id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST) +X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail1.grosbedon.com +X-Spam-Level: +X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, + HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 +Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) + by mail1.grosbedon.com (Postfix) with ESMTPS id 9BBD7BFAAA + for ; Fri, 23 Aug 2013 13:17:55 +0200 (CEST) +Received: by mail-ie0-f173.google.com with SMTP id qd12so575130ieb.4 + for ; Fri, 23 Aug 2013 04:17:54 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20120113; + h=mime-version:date:message-id:subject:from:to:content-type; + bh=dMNHV52EC7GAa7+9a9tqwT9joy9z+1950J/3A6/M/hU=; + b=DGuv0VjegdSrEe36ADC8XZ9Inrb3Iu+3/52Bm+caltddXFH9yewTr0JkCRQaJgMwG9 + qXTQgP8qu/VFEbCh6scu5ZgU1hknzlNCYr3LT+Ih7dAZVUEHUJdwjzUU1LFV95G2RaCd + /Lwff6CibuUvrA+0CBO7IRKW0Sn5j0mukYu8dbaKsm6ou6HqS8Nuj85fcXJfHSHp6Y9u + dmE8jBh3fHCHF/nAvU+8aBNSIzl1FGfiBYb2jCoapIuVFitKR4q5cuoodpkH9XqqtOdH + DG+YjEyi8L7uvdOfN16eMr7hfUkQei1yQgvGu9/5kXoHg9+Gx6VsZIycn4zoaXTV3Nhn + nu4g== +MIME-Version: 1.0 +X-Received: by 10.50.124.65 with SMTP id mg1mr1144467igb.43.1377256674216; + Fri, 23 Aug 2013 04:17:54 -0700 (PDT) +Received: by 10.43.99.71 with HTTP; Fri, 23 Aug 2013 04:17:54 -0700 (PDT) +Date: Fri, 23 Aug 2013 13:17:54 +0200 +Message-ID: +Subject: Test mail multipart/mixed +From: =?ISO-8859-1?Q?Raoul Grosbedon=E9e?= +To: Followers of ASUSTeK-Joseph-Walters +Content-Type: multipart/mixed; boundary=089e01536c4ed4d17204e49b8e96 + +--089e01536c4ed4d17204e49b8e96 +Content-Type: multipart/alternative; boundary=089e01536c4ed4d16d04e49b8e94 + +--089e01536c4ed4d16d04e49b8e94 +Content-Type: text/plain; charset=ISO-8859-1 + +Should create a multipart/mixed: from gmail, *bold*, with attachment. + +-- +Marcel Boitempoils. + +--089e01536c4ed4d16d04e49b8e94 +Content-Type: text/html; charset=ISO-8859-1 + +

Should create a multipart/mixed: from gmail, bold, with attachment.

--
Marcel Boitempoils.
+ +--089e01536c4ed4d16d04e49b8e94-- +--089e01536c4ed4d17204e49b8e96 +Content-Type: text/plain; charset=US-ASCII; name="test.txt" +Content-Disposition: attachment; filename="test.txt" +Content-Transfer-Encoding: base64 +X-Attachment-Id: f_hkpb27k00 + +dGVzdAo= +--089e01536c4ed4d17204e49b8e96--""" + +MAIL_MULTIPART_MIXED_TWO = """X-Original-To: raoul@grosbedon.fr +Delivered-To: raoul@grosbedon.fr +Received: by mail1.grosbedon.com (Postfix, from userid 10002) + id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST) +From: "Bruce Wayne" +Content-Type: multipart/alternative; + boundary="Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227" +Message-Id: <6BB1FAB2-2104-438E-9447-07AE2C8C4A92@sexample.com> +Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) + +--Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=us-ascii + +First and second part + +--Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227 +Content-Type: multipart/mixed; + boundary="Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F" + +--Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F +Content-Transfer-Encoding: 7bit +Content-Type: text/html; + charset=us-ascii + +First part + +--Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F +Content-Disposition: inline; + filename=thetruth.pdf +Content-Type: application/pdf; + name="thetruth.pdf" +Content-Transfer-Encoding: base64 + +SSBhbSB0aGUgQmF0TWFuCg== + +--Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F +Content-Transfer-Encoding: 7bit +Content-Type: text/html; + charset=us-ascii + +Second part +--Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F-- + +--Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227-- +""" + + +MAIL_MULTIPART_IMAGE = """X-Original-To: raoul@example.com +Delivered-To: micheline@example.com +Received: by mail1.example.com (Postfix, from userid 99999) + id 9DFB7BF509; Thu, 17 Dec 2015 15:22:56 +0100 (CET) +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.example.com +X-Spam-Level: * +X-Spam-Status: No, score=1.1 required=5.0 tests=FREEMAIL_FROM, + HTML_IMAGE_ONLY_08,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, + RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 +Received: from mail-lf0-f44.example.com (mail-lf0-f44.example.com [209.85.215.44]) + by mail1.example.com (Postfix) with ESMTPS id 1D80DBF509 + for ; Thu, 17 Dec 2015 15:22:56 +0100 (CET) +Authentication-Results: mail1.example.com; dkim=pass + reason="2048-bit key; unprotected key" + header.d=example.com header.i=@example.com header.b=kUkTIIlt; + dkim-adsp=pass; dkim-atps=neutral +Received: by mail-lf0-f44.example.com with SMTP id z124so47959461lfa.3 + for ; Thu, 17 Dec 2015 06:22:56 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=example.com; s=20120113; + h=mime-version:date:message-id:subject:from:to:content-type; + bh=GdrEuMrz6vxo/Z/F+mJVho/1wSe6hbxLx2SsP8tihzw=; + b=kUkTIIlt6fe4dftKHPNBkdHU2rO052o684R0e2bqH7roGUQFb78scYE+kqX0wo1zlk + zhKPVBR1TqTsYlqcHu+D3aUzai7L/Q5m40sSGn7uYGkZJ6m1TwrWNqVIgTZibarqvy94 + NWhrjjK9gqd8segQdSjCgTipNSZME4bJCzPyBg/D5mqe07FPBJBGoF9SmIzEBhYeqLj1 + GrXjb/D8J11aOyzmVvyt+bT+oeLUJI8E7qO5g2eQkMncyu+TyIXaRofOOBA14NhQ+0nS + w5O9rzzqkKuJEG4U2TJ2Vi2nl2tHJW2QPfTtFgcCzGxQ0+5n88OVlbGTLnhEIJ/SYpem + O5EA== +MIME-Version: 1.0 +X-Received: by 10.25.167.197 with SMTP id q188mr22222517lfe.129.1450362175493; + Thu, 17 Dec 2015 06:22:55 -0800 (PST) +Received: by 10.25.209.145 with HTTP; Thu, 17 Dec 2015 06:22:55 -0800 (PST) +Date: Thu, 17 Dec 2015 15:22:55 +0100 +Message-ID: +Subject: {subject} +From: =?UTF-8?Q?Thibault_Delavall=C3=A9e?= +To: {to} +Content-Type: multipart/related; boundary=001a11416b9e9b229a05272b7052 + +--001a11416b9e9b229a05272b7052 +Content-Type: multipart/alternative; boundary=001a11416b9e9b229805272b7051 + +--001a11416b9e9b229805272b7051 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Premi=C3=A8re image, orang=C3=A9e. + +[image: Inline image 1] + +Seconde image, rosa=C3=A7=C3=A9e. + +[image: Inline image 2] + +Troisi=C3=A8me image, verte!=C2=B5 + +[image: Inline image 3] + +J'esp=C3=A8re que tout se passera bien. +--=20 +Thibault Delavall=C3=A9e + +--001a11416b9e9b229805272b7051 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +
Premi=C3=A8re image, orang=C3=A9e.

3D"Inline

Seconde image, rosa=C3=A7=C3= +=A9e.

3D"=

Troisi= +=C3=A8me image, verte!=C2=B5

3D"Inline

J'esp=C3=A8re que tout se passera bien.
--
Thibault Delavall=C3=A9e
+
+ +--001a11416b9e9b229805272b7051-- +--001a11416b9e9b229a05272b7052 +Content-Type: image/gif; name="=?UTF-8?B?b3JhbmfDqWUuZ2lm?=" +Content-Disposition: inline; filename="=?UTF-8?B?b3JhbmfDqWUuZ2lm?=" +Content-Transfer-Encoding: base64 +Content-ID: +X-Attachment-Id: ii_151b519fc025fdd3 + +R0lGODdhAgACALMAAAAAAP///wAAAP//AP8AAP+AAAD/AAAAAAAA//8A/wAAAAAAAAAAAAAAAAAA +AAAAACwAAAAAAgACAAAEA7DIEgA7 +--001a11416b9e9b229a05272b7052 +Content-Type: image/gif; name="=?UTF-8?B?dmVydGUhwrUuZ2lm?=" +Content-Disposition: inline; filename="=?UTF-8?B?dmVydGUhwrUuZ2lm?=" +Content-Transfer-Encoding: base64 +Content-ID: +X-Attachment-Id: ii_151b51a37e5eb7a6 + +R0lGODlhCgAKALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD/ +/////ywAAAAACgAKAAAEClDJSau9OOvNe44AOw== +--001a11416b9e9b229a05272b7052 +Content-Type: image/gif; name="=?UTF-8?B?cm9zYcOnw6llLmdpZg==?=" +Content-Disposition: inline; filename="=?UTF-8?B?cm9zYcOnw6llLmdpZg==?=" +Content-Transfer-Encoding: base64 +Content-ID: +X-Attachment-Id: ii_151b51a290ed6a91 + +R0lGODdhAgACALMAAAAAAP///wAAAP//AP8AAP+AAAD/AAAAAAAA//8A/wAAAP+AgAAAAAAAAAAA +AAAAACwAAAAAAgACAAAEA3DJFQA7 +--001a11416b9e9b229a05272b7052-- +""" \ No newline at end of file diff --git a/addons/mail/tests/models/__init__.py b/addons/mail/tests/models/__init__.py new file mode 100644 index 00000000000..420d064776c --- /dev/null +++ b/addons/mail/tests/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_mail_models \ No newline at end of file diff --git a/addons/mail/tests/test_mail_model.py b/addons/mail/tests/models/test_mail_models.py similarity index 100% rename from addons/mail/tests/test_mail_model.py rename to addons/mail/tests/models/test_mail_models.py diff --git a/addons/mail/tests/test_discuss.py b/addons/mail/tests/test_discuss.py new file mode 100644 index 00000000000..6e4baae8e27 --- /dev/null +++ b/addons/mail/tests/test_discuss.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.mail.tests.common import TestMail +from odoo.tools import mute_logger + + +class TestDiscuss(TestMail): + # TDE TODO: tests on the redirection controller + + def test_alias_setup(self): + alias = self.env['mail.alias'].with_context(alias_model_name='mail.test').create({'alias_name': 'b4r+_#_R3wl$$'}) + self.assertEqual(alias.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens') + + def test_10_cache_invalidation(self): + """ Test that creating a mail-thread record does not invalidate the whole cache. """ + # make a new record in cache + record = self.env['res.partner'].new({'name': 'Brave New Partner'}) + self.assertTrue(record.name) + + # creating a mail-thread record should not invalidate the whole cache + self.env['res.partner'].create({'name': 'Actual Partner'}) + self.assertTrue(record.name) + + + @mute_logger('odoo.addons.mail.models.mail_mail') + def test_needaction(self): + # needaction use Inbox notification + (self.user_employee | self.user_admin).write({'notification_type': 'inbox'}) + + na_emp1_base = self.test_pigs.sudo(self.user_employee).message_needaction_counter + na_emp2_base = self.test_pigs.sudo().message_needaction_counter + + self.test_pigs.message_post(body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[self.user_employee.partner_id.id]) + + na_emp1_new = self.test_pigs.sudo(self.user_employee).message_needaction_counter + na_emp2_new = self.test_pigs.sudo().message_needaction_counter + self.assertEqual(na_emp1_new, na_emp1_base + 1) + self.assertEqual(na_emp2_new, na_emp2_base) + + def test_message_set_star(self): + msg = self.test_pigs.message_post(body='My Body', subject='1') + msg_emp = self.env['mail.message'].sudo(self.user_employee).browse(msg.id) + + # Admin set as starred + msg.toggle_message_starred() + self.assertTrue(msg.starred) + + # Employee set as starred + msg_emp.toggle_message_starred() + self.assertTrue(msg_emp.starred) + + # Do: Admin unstars msg + msg.toggle_message_starred() + self.assertFalse(msg.starred) + self.assertTrue(msg_emp.starred) + + def test_60_cache_invalidation(self): + msg_cnt = len(self.test_pigs.message_ids) + self.test_pigs.message_post(body='Hi!', subject='test') + self.assertEqual(len(self.test_pigs.message_ids), msg_cnt + 1) diff --git a/addons/mail/tests/test_mail_gateway.py b/addons/mail/tests/test_mail_gateway.py index 2a356d9ed13..bc8160f4d9a 100644 --- a/addons/mail/tests/test_mail_gateway.py +++ b/addons/mail/tests/test_mail_gateway.py @@ -3,289 +3,11 @@ import socket +from odoo.addons.mail.tests.data.test_mail_data import MAIL_TEMPLATE, MAIL_TEMPLATE_PLAINTEXT, MAIL_MULTIPART_MIXED, MAIL_MULTIPART_MIXED_TWO, MAIL_MULTIPART_IMAGE from odoo.addons.mail.tests.common import TestMail from odoo.tools import mute_logger -MAIL_TEMPLATE = """Return-Path: -To: {to} -cc: {cc} -Received: by mail1.openerp.com (Postfix, from userid 10002) - id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST) -From: {email_from} -Subject: {subject} -MIME-Version: 1.0 -Content-Type: multipart/alternative; - boundary="----=_Part_4200734_24778174.1344608186754" -Date: Fri, 10 Aug 2012 14:16:26 +0000 -Message-ID: {msg_id} -{extra} -------=_Part_4200734_24778174.1344608186754 -Content-Type: text/plain; charset=utf-8 -Content-Transfer-Encoding: quoted-printable - -Please call me as soon as possible this afternoon! - --- -Sylvie -------=_Part_4200734_24778174.1344608186754 -Content-Type: text/html; charset=utf-8 -Content-Transfer-Encoding: quoted-printable - - - - =20 - - =20 - =20 - -

Please call me as soon as possible this afternoon!

- -

--
- Sylvie -

- - -------=_Part_4200734_24778174.1344608186754-- -""" - -MAIL_TEMPLATE_PLAINTEXT = """Return-Path: -To: {to} -Received: by mail1.openerp.com (Postfix, from userid 10002) - id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST) -From: Sylvie Lelitre -Subject: {subject} -MIME-Version: 1.0 -Content-Type: text/plain -Date: Fri, 10 Aug 2012 14:16:26 +0000 -Message-ID: {msg_id} -{extra} - -Please call me as soon as possible this afternoon! - --- -Sylvie -""" - -MAIL_MULTIPART_MIXED = """Return-Path: -X-Original-To: raoul@grosbedon.fr -Delivered-To: raoul@grosbedon.fr -Received: by mail1.grosbedon.com (Postfix, from userid 10002) - id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail1.grosbedon.com -X-Spam-Level: -X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, - HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 -Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) - by mail1.grosbedon.com (Postfix) with ESMTPS id 9BBD7BFAAA - for ; Fri, 23 Aug 2013 13:17:55 +0200 (CEST) -Received: by mail-ie0-f173.google.com with SMTP id qd12so575130ieb.4 - for ; Fri, 23 Aug 2013 04:17:54 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20120113; - h=mime-version:date:message-id:subject:from:to:content-type; - bh=dMNHV52EC7GAa7+9a9tqwT9joy9z+1950J/3A6/M/hU=; - b=DGuv0VjegdSrEe36ADC8XZ9Inrb3Iu+3/52Bm+caltddXFH9yewTr0JkCRQaJgMwG9 - qXTQgP8qu/VFEbCh6scu5ZgU1hknzlNCYr3LT+Ih7dAZVUEHUJdwjzUU1LFV95G2RaCd - /Lwff6CibuUvrA+0CBO7IRKW0Sn5j0mukYu8dbaKsm6ou6HqS8Nuj85fcXJfHSHp6Y9u - dmE8jBh3fHCHF/nAvU+8aBNSIzl1FGfiBYb2jCoapIuVFitKR4q5cuoodpkH9XqqtOdH - DG+YjEyi8L7uvdOfN16eMr7hfUkQei1yQgvGu9/5kXoHg9+Gx6VsZIycn4zoaXTV3Nhn - nu4g== -MIME-Version: 1.0 -X-Received: by 10.50.124.65 with SMTP id mg1mr1144467igb.43.1377256674216; - Fri, 23 Aug 2013 04:17:54 -0700 (PDT) -Received: by 10.43.99.71 with HTTP; Fri, 23 Aug 2013 04:17:54 -0700 (PDT) -Date: Fri, 23 Aug 2013 13:17:54 +0200 -Message-ID: -Subject: Test mail multipart/mixed -From: =?ISO-8859-1?Q?Raoul Grosbedon=E9e?= -To: Followers of ASUSTeK-Joseph-Walters -Content-Type: multipart/mixed; boundary=089e01536c4ed4d17204e49b8e96 - ---089e01536c4ed4d17204e49b8e96 -Content-Type: multipart/alternative; boundary=089e01536c4ed4d16d04e49b8e94 - ---089e01536c4ed4d16d04e49b8e94 -Content-Type: text/plain; charset=ISO-8859-1 - -Should create a multipart/mixed: from gmail, *bold*, with attachment. - --- -Marcel Boitempoils. - ---089e01536c4ed4d16d04e49b8e94 -Content-Type: text/html; charset=ISO-8859-1 - -

Should create a multipart/mixed: from gmail, bold, with attachment.

--
Marcel Boitempoils.
- ---089e01536c4ed4d16d04e49b8e94-- ---089e01536c4ed4d17204e49b8e96 -Content-Type: text/plain; charset=US-ASCII; name="test.txt" -Content-Disposition: attachment; filename="test.txt" -Content-Transfer-Encoding: base64 -X-Attachment-Id: f_hkpb27k00 - -dGVzdAo= ---089e01536c4ed4d17204e49b8e96--""" - -MAIL_MULTIPART_MIXED_TWO = """X-Original-To: raoul@grosbedon.fr -Delivered-To: raoul@grosbedon.fr -Received: by mail1.grosbedon.com (Postfix, from userid 10002) - id E8166BFACA; Fri, 23 Aug 2013 13:18:01 +0200 (CEST) -From: "Bruce Wayne" -Content-Type: multipart/alternative; - boundary="Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227" -Message-Id: <6BB1FAB2-2104-438E-9447-07AE2C8C4A92@sexample.com> -Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) - ---Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227 -Content-Transfer-Encoding: 7bit -Content-Type: text/plain; - charset=us-ascii - -First and second part - ---Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227 -Content-Type: multipart/mixed; - boundary="Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F" - ---Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F -Content-Transfer-Encoding: 7bit -Content-Type: text/html; - charset=us-ascii - -First part - ---Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F -Content-Disposition: inline; - filename=thetruth.pdf -Content-Type: application/pdf; - name="thetruth.pdf" -Content-Transfer-Encoding: base64 - -SSBhbSB0aGUgQmF0TWFuCg== - ---Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F -Content-Transfer-Encoding: 7bit -Content-Type: text/html; - charset=us-ascii - -Second part ---Apple-Mail=_CA6C687E-6AA0-411E-B0FE-F0ABB4CFED1F-- - ---Apple-Mail=_9331E12B-8BD2-4EC7-B53E-01F3FBEC9227-- -""" - - -MAIL_MULTIPART_IMAGE = """X-Original-To: raoul@example.com -Delivered-To: micheline@example.com -Received: by mail1.example.com (Postfix, from userid 99999) - id 9DFB7BF509; Thu, 17 Dec 2015 15:22:56 +0100 (CET) -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.example.com -X-Spam-Level: * -X-Spam-Status: No, score=1.1 required=5.0 tests=FREEMAIL_FROM, - HTML_IMAGE_ONLY_08,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, - RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 -Received: from mail-lf0-f44.example.com (mail-lf0-f44.example.com [209.85.215.44]) - by mail1.example.com (Postfix) with ESMTPS id 1D80DBF509 - for ; Thu, 17 Dec 2015 15:22:56 +0100 (CET) -Authentication-Results: mail1.example.com; dkim=pass - reason="2048-bit key; unprotected key" - header.d=example.com header.i=@example.com header.b=kUkTIIlt; - dkim-adsp=pass; dkim-atps=neutral -Received: by mail-lf0-f44.example.com with SMTP id z124so47959461lfa.3 - for ; Thu, 17 Dec 2015 06:22:56 -0800 (PST) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=example.com; s=20120113; - h=mime-version:date:message-id:subject:from:to:content-type; - bh=GdrEuMrz6vxo/Z/F+mJVho/1wSe6hbxLx2SsP8tihzw=; - b=kUkTIIlt6fe4dftKHPNBkdHU2rO052o684R0e2bqH7roGUQFb78scYE+kqX0wo1zlk - zhKPVBR1TqTsYlqcHu+D3aUzai7L/Q5m40sSGn7uYGkZJ6m1TwrWNqVIgTZibarqvy94 - NWhrjjK9gqd8segQdSjCgTipNSZME4bJCzPyBg/D5mqe07FPBJBGoF9SmIzEBhYeqLj1 - GrXjb/D8J11aOyzmVvyt+bT+oeLUJI8E7qO5g2eQkMncyu+TyIXaRofOOBA14NhQ+0nS - w5O9rzzqkKuJEG4U2TJ2Vi2nl2tHJW2QPfTtFgcCzGxQ0+5n88OVlbGTLnhEIJ/SYpem - O5EA== -MIME-Version: 1.0 -X-Received: by 10.25.167.197 with SMTP id q188mr22222517lfe.129.1450362175493; - Thu, 17 Dec 2015 06:22:55 -0800 (PST) -Received: by 10.25.209.145 with HTTP; Thu, 17 Dec 2015 06:22:55 -0800 (PST) -Date: Thu, 17 Dec 2015 15:22:55 +0100 -Message-ID: -Subject: {subject} -From: =?UTF-8?Q?Thibault_Delavall=C3=A9e?= -To: {to} -Content-Type: multipart/related; boundary=001a11416b9e9b229a05272b7052 - ---001a11416b9e9b229a05272b7052 -Content-Type: multipart/alternative; boundary=001a11416b9e9b229805272b7051 - ---001a11416b9e9b229805272b7051 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -Premi=C3=A8re image, orang=C3=A9e. - -[image: Inline image 1] - -Seconde image, rosa=C3=A7=C3=A9e. - -[image: Inline image 2] - -Troisi=C3=A8me image, verte!=C2=B5 - -[image: Inline image 3] - -J'esp=C3=A8re que tout se passera bien. ---=20 -Thibault Delavall=C3=A9e - ---001a11416b9e9b229805272b7051 -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -
Premi=C3=A8re image, orang=C3=A9e.

3D"Inline

Seconde image, rosa=C3=A7=C3= -=A9e.

3D"=

Troisi= -=C3=A8me image, verte!=C2=B5

3D"Inline

J'esp=C3=A8re que tout se passera bien.
--
Thibault Delavall=C3=A9e
-
- ---001a11416b9e9b229805272b7051-- ---001a11416b9e9b229a05272b7052 -Content-Type: image/gif; name="=?UTF-8?B?b3JhbmfDqWUuZ2lm?=" -Content-Disposition: inline; filename="=?UTF-8?B?b3JhbmfDqWUuZ2lm?=" -Content-Transfer-Encoding: base64 -Content-ID: -X-Attachment-Id: ii_151b519fc025fdd3 - -R0lGODdhAgACALMAAAAAAP///wAAAP//AP8AAP+AAAD/AAAAAAAA//8A/wAAAAAAAAAAAAAAAAAA -AAAAACwAAAAAAgACAAAEA7DIEgA7 ---001a11416b9e9b229a05272b7052 -Content-Type: image/gif; name="=?UTF-8?B?dmVydGUhwrUuZ2lm?=" -Content-Disposition: inline; filename="=?UTF-8?B?dmVydGUhwrUuZ2lm?=" -Content-Transfer-Encoding: base64 -Content-ID: -X-Attachment-Id: ii_151b51a37e5eb7a6 - -R0lGODlhCgAKALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD/ -/////ywAAAAACgAKAAAEClDJSau9OOvNe44AOw== ---001a11416b9e9b229a05272b7052 -Content-Type: image/gif; name="=?UTF-8?B?cm9zYcOnw6llLmdpZg==?=" -Content-Disposition: inline; filename="=?UTF-8?B?cm9zYcOnw6llLmdpZg==?=" -Content-Transfer-Encoding: base64 -Content-ID: -X-Attachment-Id: ii_151b51a290ed6a91 - -R0lGODdhAgACALMAAAAAAP///wAAAP//AP8AAP+AAAD/AAAAAAAA//8A/wAAAP+AgAAAAAAAAAAA -AAAAACwAAAAAAgACAAAEA3DJFQA7 ---001a11416b9e9b229a05272b7052-- -""" - - class TestMailgateway(TestMail): def setUp(self): @@ -773,7 +495,7 @@ class TestMailgateway(TestMail): self.assertTrue(msg_fw.res_id == channel.id) # tmp - from odoo.addons.mail.tests.test_mail_model import MailTest + from odoo.addons.mail.tests.models.test_mail_models import MailTest MailTest._mail_flat_thread = False fw_msg_id = '' diff --git a/addons/mail/tests/test_mail_message.py b/addons/mail/tests/test_mail_message.py index 148ff0ed0d2..f8ae1064c80 100644 --- a/addons/mail/tests/test_mail_message.py +++ b/addons/mail/tests/test_mail_message.py @@ -266,25 +266,3 @@ class TestMailMessageAccess(TestMail): def test_mail_message_access_create_reply(self): self.message.write({'partner_ids': [(4, self.user_employee.partner_id.id)]}) self.env['mail.message'].sudo(self.user_employee).create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test', 'parent_id': self.message.id}) - - def test_message_set_star(self): - msg = self.test_pigs.message_post(body='My Body', subject='1') - msg_emp = self.env['mail.message'].sudo(self.user_employee).browse(msg.id) - - # Admin set as starred - msg.toggle_message_starred() - self.assertTrue(msg.starred) - - # Employee set as starred - msg_emp.toggle_message_starred() - self.assertTrue(msg_emp.starred) - - # Do: Admin unstars msg - msg.toggle_message_starred() - self.assertFalse(msg.starred) - self.assertTrue(msg_emp.starred) - - def test_60_cache_invalidation(self): - msg_cnt = len(self.test_pigs.message_ids) - self.test_pigs.message_post(body='Hi!', subject='test') - self.assertEqual(len(self.test_pigs.message_ids), msg_cnt + 1) diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_message_compose.py similarity index 91% rename from addons/mail/tests/test_mail_features.py rename to addons/mail/tests/test_message_compose.py index 8e2264ad6d3..791ead4ef20 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_message_compose.py @@ -7,40 +7,6 @@ from odoo.addons.mail.tests.test_mail_gateway import MAIL_TEMPLATE_PLAINTEXT from odoo.tools import mute_logger -class TestMailFeatures(TestMail): - # TDE TODO: tests on the redirection controller - - def test_alias_setup(self): - alias = self.env['mail.alias'].with_context(alias_model_name='mail.test').create({'alias_name': 'b4r+_#_R3wl$$'}) - self.assertEqual(alias.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens') - - def test_10_cache_invalidation(self): - """ Test that creating a mail-thread record does not invalidate the whole cache. """ - # make a new record in cache - record = self.env['res.partner'].new({'name': 'Brave New Partner'}) - self.assertTrue(record.name) - - # creating a mail-thread record should not invalidate the whole cache - self.env['res.partner'].create({'name': 'Actual Partner'}) - self.assertTrue(record.name) - - - @mute_logger('odoo.addons.mail.models.mail_mail') - def test_needaction(self): - # needaction use Inbox notification - (self.user_employee | self.user_admin).write({'notification_type': 'inbox'}) - - na_emp1_base = self.test_pigs.sudo(self.user_employee).message_needaction_counter - na_emp2_base = self.test_pigs.sudo().message_needaction_counter - - self.test_pigs.message_post(body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[self.user_employee.partner_id.id]) - - na_emp1_new = self.test_pigs.sudo(self.user_employee).message_needaction_counter - na_emp2_new = self.test_pigs.sudo().message_needaction_counter - self.assertEqual(na_emp1_new, na_emp1_base + 1) - self.assertEqual(na_emp2_new, na_emp2_base) - - class TestMessagePost(TestMail): @mute_logger('odoo.addons.mail.models.mail_mail') @@ -252,6 +218,35 @@ class TestMessagePost(TestMail): # TODO: test attachments ? + def test_mail_compose_access_rights(self): + test_channel = self.env['mail.channel'].create({ + 'name': 'Pigs', + 'public': 'groups', + 'group_public_id': self.env.ref('base.group_portal').id}) + port_msg = test_channel.message_post(body='Message') + + # Do: Chell comments Pigs, ok because can write on it (public group) + test_channel.sudo(self.user_portal).message_post(body='I love Pigs', message_type='comment', subtype='mail.mt_comment') + # Do: Chell creates a mail.compose.message record on Pigs, because he uses the wizard + compose = self.env['mail.compose.message'].with_context({ + 'default_composition_mode': 'comment', + 'default_model': 'mail.channel', + 'default_res_id': test_channel.id + }).sudo(self.user_portal).create({ + 'subject': 'Subject', + 'body': 'Body text', + 'partner_ids': []}) + compose.send_mail() + + # Do: Chell replies to a Pigs message using the composer + compose = self.env['mail.compose.message'].with_context({ + 'default_composition_mode': 'comment', + 'default_parent_id': port_msg.id + }).sudo(self.user_portal).create({ + 'subject': 'Subject', + 'body': 'Body text'}) + compose.send_mail() + @mute_logger('odoo.addons.mail.models.mail_mail') def test_message_compose_mass_mail(self): composer = self.env['mail.compose.message'].with_context({ diff --git a/addons/mail/tests/test_portal.py b/addons/mail/tests/test_portal.py deleted file mode 100644 index 774e2a6e328..00000000000 --- a/addons/mail/tests/test_portal.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo.addons.mail.tests.common import TestMail -from odoo.tools.misc import mute_logger - - -class TestPortal(TestMail): - - def test_mail_compose_access_rights(self): - test_channel = self.env['mail.channel'].create({ - 'name': 'Pigs', - 'public': 'groups', - 'group_public_id': self.env.ref('base.group_portal').id}) - port_msg = test_channel.message_post(body='Message') - - # Do: Chell comments Pigs, ok because can write on it (public group) - test_channel.sudo(self.user_portal).message_post(body='I love Pigs', message_type='comment', subtype='mail.mt_comment') - # Do: Chell creates a mail.compose.message record on Pigs, because he uses the wizard - compose = self.env['mail.compose.message'].with_context({ - 'default_composition_mode': 'comment', - 'default_model': 'mail.channel', - 'default_res_id': test_channel.id - }).sudo(self.user_portal).create({ - 'subject': 'Subject', - 'body': 'Body text', - 'partner_ids': []}) - compose.send_mail() - - # Do: Chell replies to a Pigs message using the composer - compose = self.env['mail.compose.message'].with_context({ - 'default_composition_mode': 'comment', - 'default_parent_id': port_msg.id - }).sudo(self.user_portal).create({ - 'subject': 'Subject', - 'body': 'Body text'}) - compose.send_mail() - - @mute_logger('odoo.addons.mail.models.mail_mail') - def test_invite_email_portal(self): - test_record = self.env['mail.test'].create({'name': 'Pigs'}) - - base_url = self.env['ir.config_parameter'].get_param('web.base.url', default='') - # Carine Poilvache, with email, should receive emails for comments and emails - partner_carine = self.env['res.partner'].create({'name': 'Carine Poilvache', 'email': 'c@c'}) - - # Do: create a mail_wizard_invite, validate it - self._init_mock_build_email() - mail_invite = self.env['mail.wizard.invite'].with_context({ - 'default_res_model': 'mail.test', - 'default_res_id': test_record.id}).create({ - 'partner_ids': [(4, partner_carine.id)], 'send_mail': True}) - mail_invite.add_followers() - # Test: Pigs followers should contain Admin and Bert - self.assertIn(partner_carine, test_record.message_partner_ids) - # Test: partner must have been prepared for signup - # TDE FIXME: invite email for portal users should be fixed / improved / rethought - # self.assertTrue(partner_carine.signup_valid, 'partner has not been prepared for signup') - # self.assertTrue(base_url in partner_carine.signup_url, 'signup url is incorrect') - # self.assertTrue(self.env.cr.dbname in partner_carine.signup_url, 'signup url is incorrect') - # self.assertTrue(partner_carine.signup_token in partner_carine.signup_url, 'signup url is incorrect') - # Test: (pretend to) send email and check subject, body - self.assertEqual(len(self._mails), 1, 'sent email number incorrect, should be only for Bert') - for sent_email in self._mails: - self.assertEqual( - sent_email.get('subject'), 'Invitation to follow %s: Pigs' % self.env['mail.test']._description, - 'invite: subject of invitation email is incorrect') - self.assertIn( - 'Administrator invited you to follow %s document: Pigs' % self.env['mail.test']._description, sent_email.get('body'), - 'invite: body of invitation email is incorrect') - # self.assertIn( - # partner_carine.signup_token, sent_email.get('body'), - # 'invite: body of invitation email does not contain signup token')