summaryrefslogtreecommitdiff
path: root/addons/test_mail/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/tests/common.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/test_mail/tests/common.py')
-rw-r--r--addons/test_mail/tests/common.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/addons/test_mail/tests/common.py b/addons/test_mail/tests/common.py
new file mode 100644
index 00000000..c556a988
--- /dev/null
+++ b/addons/test_mail/tests/common.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.addons.mail.tests.common import MailCommon
+from odoo.tests.common import SavepointCase
+
+
+class TestMailCommon(MailCommon):
+ """ Main entry point for functional tests. """
+
+ @classmethod
+ def _create_channel_listener(cls):
+ cls.channel_listen = cls.env['mail.channel'].with_context(cls._test_context).create({'name': 'Listener'})
+
+ @classmethod
+ def _create_records_for_batch(cls, model, count):
+ # TDE note: to be cleaned in master
+ records = cls.env[model]
+ partners = cls.env['res.partner']
+ country_id = cls.env.ref('base.be').id
+
+ partners = cls.env['res.partner'].with_context(**cls._test_context).create([{
+ 'name': 'Partner_%s' % (x),
+ 'email': '_test_partner_%s@example.com' % (x),
+ 'country_id': country_id,
+ 'mobile': '047500%02d%02d' % (x, x)
+ } for x in range(count)])
+
+ records = cls.env[model].with_context(**cls._test_context).create([{
+ 'name': 'Test_%s' % (x),
+ 'customer_id': partners[x].id,
+ } for x in range(count)])
+
+ cls.records = cls._reset_mail_context(records)
+ cls.partners = partners
+ return cls.records, cls.partners
+
+
+class TestMailMultiCompanyCommon(MailCommon):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestMailMultiCompanyCommon, cls).setUpClass()
+ cls.company_2 = cls.env['res.company'].create({
+ 'name': 'Second Test Company',
+ })
+
+
+class TestRecipients(SavepointCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestRecipients, cls).setUpClass()
+ Partner = cls.env['res.partner'].with_context({
+ 'mail_create_nolog': True,
+ 'mail_create_nosubscribe': True,
+ 'mail_notrack': True,
+ 'no_reset_password': True,
+ })
+ cls.partner_1 = Partner.create({
+ 'name': 'Valid Lelitre',
+ 'email': 'valid.lelitre@agrolait.com',
+ 'country_id': cls.env.ref('base.be').id,
+ 'mobile': '0456001122',
+ })
+ cls.partner_2 = Partner.create({
+ 'name': 'Valid Poilvache',
+ 'email': 'valid.other@gmail.com',
+ 'country_id': cls.env.ref('base.be').id,
+ 'mobile': '+32 456 22 11 00',
+ })