[ADD] test_mass_mailing: add module to hold feature and performance tests for mass mailing

Purpose of this commit is to add the skeleton of a module holding models and
tests for mass mailing. It is build on top of test_mail in order to use
data, models and parameters already defined in it. Moreover having a
separate module allow to define test models that will not bloat production
databases.

It will soon hold unit tests for blacklist mechanism. Future commits will
gradually move tests from mass mailing module and improve them.

This commit is related to task ID 33224 (original blacklist implementation
done for v12) and its PR #25966 as well as task ID 1889703 (tests and fixes)
and its PR #27330. Done with collaboration of @dbeguin.
This commit is contained in:
Thibault Delavallée
2018-10-02 16:32:53 +02:00
parent 4b3884b0d7
commit fca1654dc5
7 changed files with 98 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+20
View File
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
{
'name': 'Mass Mail Tests',
'version': '1.0',
'category': 'Hidden',
'sequence': 8765,
'summary': 'Mass Mail Tests: feature and performance tests for mass mailing',
'description': """This module contains tests related to mass mailing. Those
are contained in a separate module to use specific test models defined in
test_mail. """,
'depends': ['test_mail', 'mass_mailing'],
'data': [
'security/ir.model.access.csv',
],
'demo': [
],
'installable': True,
'application': False,
}
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import mass_mail_test
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class MassMailTest(models.Model):
""" A very simple model only inheriting from mail.thread to test pure mass
mailing features and base performances. """
_description = 'Simple Mass Mailing Model'
_name = 'mass.mail.test'
_inherit = ['mail.thread']
name = fields.Char()
email_from = fields.Char()
class MassMailTestBlacklist(models.Model):
""" Model using blacklist mechanism for mass mailing. """
_description = 'Mass Mailing Model w Blacklist'
_name = 'mass.mail.test.bl'
_inherit = ['mail.thread', 'mail.blacklist.mixin']
_primary_email = ['email_from'] # blacklist field to check
name = fields.Char()
email_from = fields.Char()
user_id = fields.Many2one(
'res.users', 'Responsible',
track_visibility='onchange')
umbrella_id = fields.Many2one(
'mail.test', 'Meta Umbrella Record',
track_visibility='onchange')
@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mass_mail_test_all,mass.mail.test.all,model_mass_mail_test,,0,0,0,0
access_mass_mail_test_user,mass.mail.test.user,model_mass_mail_test,base.group_user,1,1,1,1
access_mass_mail_test_bl_all,mass.mail.test.bl.all,model_mass_mail_test_bl,,0,0,0,0
access_mass_mail_test_bl_user,mass.mail.test.bl.user,model_mass_mail_test_bl,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_mass_mail_test_all mass.mail.test.all model_mass_mail_test 0 0 0 0
3 access_mass_mail_test_user mass.mail.test.user model_mass_mail_test base.group_user 1 1 1 1
4 access_mass_mail_test_bl_all mass.mail.test.bl.all model_mass_mail_test_bl 0 0 0 0
5 access_mass_mail_test_bl_user mass.mail.test.bl.user model_mass_mail_test_bl base.group_user 1 1 1 1
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+30
View File
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests import common
from odoo.tests import tagged
@tagged('mass_mail')
class MassMailingCase(common.MockEmails, common.BaseFunctionalTest):
@classmethod
def setUpClass(cls):
super(MassMailingCase, cls).setUpClass()
# be sure for some common data
cls.user_employee.write({
'login': 'emp',
})
cls.user_marketing = cls.env['res.users'].with_context(cls._quick_create_user_ctx).create({
'name': 'Ernest Employee',
'login': 'marketing',
'email': 'e.e@example.com',
'signature': '--\nErnest',
'notification_type': 'email',
'groups_id': [
(6, 0, [cls.env.ref('base.group_user').id]),
(6, 0, [cls.env.ref('mass_mailing.group_mass_mailing_user').id])
],
})