summaryrefslogtreecommitdiff
path: root/addons/test_mail_full/tests/common.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/test_mail_full/tests/common.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/test_mail_full/tests/common.py')
-rw-r--r--addons/test_mail_full/tests/common.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/test_mail_full/tests/common.py b/addons/test_mail_full/tests/common.py
new file mode 100644
index 00000000..e41d4880
--- /dev/null
+++ b/addons/test_mail_full/tests/common.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.addons.phone_validation.tools import phone_validation
+from odoo.addons.mass_mailing_sms.tests.common import MassSMSCommon
+from odoo.addons.test_mail.tests.common import TestRecipients
+from odoo.addons.test_mass_mailing.tests.common import TestMassMailCommon
+
+
+class TestMailFullCommon(TestMassMailCommon, MassSMSCommon):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestMailFullCommon, cls).setUpClass()
+
+ cls.mailing_sms = cls.env['mailing.mailing'].with_user(cls.user_marketing).create({
+ 'name': 'XMas SMS',
+ 'subject': 'Xmas SMS for {object.name}',
+ 'mailing_model_id': cls.env['ir.model']._get('mail.test.sms').id,
+ 'mailing_type': 'sms',
+ 'mailing_domain': '%s' % repr([('name', 'ilike', 'SMSTest')]),
+ 'body_plaintext': 'Dear ${object.display_name} this is a mass SMS with two links http://www.odoo.com/smstest and http://www.odoo.com/smstest/${object.id}',
+ 'sms_force_send': True,
+ 'sms_allow_unsubscribe': True,
+ })
+
+ @classmethod
+ def _create_mailing_sms_test_records(cls, model='mail.test.sms', partners=None, count=1):
+ """ Helper to create data. Currently simple, to be improved. """
+ Model = cls.env[model]
+ phone_field = 'phone_nbr' if 'phone_nbr' in Model else 'phone'
+ partner_field = 'customer_id' if 'customer_id' in Model else 'partner_id'
+
+ vals_list = []
+ for idx in range(count):
+ vals = {
+ 'name': 'SMSTestRecord_%02d' % idx,
+ phone_field: '045600%02d%02d' % (idx, idx)
+ }
+ if partners:
+ vals[partner_field] = partners[idx % len(partners)]
+
+ vals_list.append(vals)
+
+ return cls.env[model].create(vals_list)
+
+
+class TestRecipients(TestRecipients):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestRecipients, cls).setUpClass()
+ cls.partner_numbers = [
+ phone_validation.phone_format(partner.mobile, partner.country_id.code, partner.country_id.phone_code, force_format='E164')
+ for partner in (cls.partner_1 | cls.partner_2)
+ ]