From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/test_mass_mailing/tests/common.py | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 addons/test_mass_mailing/tests/common.py (limited to 'addons/test_mass_mailing/tests/common.py') diff --git a/addons/test_mass_mailing/tests/common.py b/addons/test_mass_mailing/tests/common.py new file mode 100644 index 00000000..ff368bf5 --- /dev/null +++ b/addons/test_mass_mailing/tests/common.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.mass_mailing.tests.common import MassMailCommon +from odoo.addons.test_mail.tests.common import TestMailCommon + + +class TestMassMailCommon(MassMailCommon, TestMailCommon): + + @classmethod + def setUpClass(cls): + super(TestMassMailCommon, cls).setUpClass() + + cls.test_alias = cls.env['mail.alias'].create({ + 'alias_name': 'test.alias', + 'alias_user_id': False, + 'alias_model_id': cls.env['ir.model']._get('mailing.test.simple').id, + 'alias_contact': 'everyone' + }) + + # enforce last update by user_marketing to match _process_mass_mailing_queue + # taking last writer as user running a batch + cls.mailing_bl = cls.env['mailing.mailing'].with_user(cls.user_marketing).create({ + 'name': 'SourceName', + 'subject': 'MailingSubject', + 'preview': 'Hi ${object.name} :)', + 'body_html': """

Hello ${object.name}

, +% set url = "www.odoo.com" +% set httpurl = "https://www.odoo.eu" +Website0: https://www.odoo.tz/my/${object.name} +Website1: https://www.odoo.be +Website2: https://${url} +Website3: ${httpurl} +External1: Youpie +Internal1: Internal link +Internal2: View link +Email: test@odoo.com +

Stop spam ? Ok

+
""", + 'mailing_type': 'mail', + 'mailing_model_id': cls.env['ir.model']._get('mailing.test.blacklist').id, + 'reply_to_mode': 'thread', + }) + + @classmethod + def _create_test_blacklist_records(cls, model='mailing.test.blacklist', count=1): + """ Deprecated, remove in 14.4 """ + return cls.__create_mailing_test_records(model=model, count=count) + + @classmethod + def _create_mailing_test_records(cls, model='mailing.test.blacklist', partners=None, count=1): + """ Helper to create data. Currently simple, to be improved. """ + Model = cls.env[model] + email_field = 'email' if 'email' in Model else 'email_from' + partner_field = 'customer_id' if 'customer_id' in Model else 'partner_id' + + vals_list = [] + for x in range(0, count): + vals = { + 'name': 'TestRecord_%02d' % x, + email_field: '"TestCustomer %02d" ' % (x, x), + } + if partners: + vals[partner_field] = partners[x % len(partners)] + + vals_list.append(vals) + + return cls.env[model].create(vals_list) -- cgit v1.2.3