[REF] project: tests: make tests independent from mail

Purpose is to be able to move mail tests in a separate module without
breaking other tests. It seems dependency is not real, only some data
to add. It is better to have self contained tests anyway.
This commit is contained in:
Thibault Delavallée
2017-11-21 15:00:21 +01:00
parent 5a2d789d1a
commit 1b2d58daec
+32 -2
View File
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from odoo.addons.mail.tests.common import TestMail
from odoo.tests.common import SavepointCase
class TestProjectBase(TestMail):
class TestProjectBase(SavepointCase):
@classmethod
def setUpClass(cls):
@@ -13,8 +13,29 @@ class TestProjectBase(TestMail):
user_group_project_user = cls.env.ref('project.group_project_user')
user_group_project_manager = cls.env.ref('project.group_project_manager')
cls.partner_1 = cls.env['res.partner'].create({
'name': 'Valid Lelitre',
'email': 'valid.lelitre@agrolait.com'})
cls.partner_2 = cls.env['res.partner'].create({
'name': 'Valid Poilvache',
'email': 'valid.other@gmail.com'})
# Test users to use through the various tests
Users = cls.env['res.users'].with_context({'no_reset_password': True})
cls.user_public = Users.create({
'name': 'Bert Tartignole',
'login': 'bert',
'email': 'b.t@example.com',
'signature': 'SignBert',
'notification_type': 'email',
'groups_id': [(6, 0, [cls.env.ref('base.group_public').id])]})
cls.user_portal = Users.create({
'name': 'Chell Gladys',
'login': 'chell',
'email': 'chell@gladys.portal',
'signature': 'SignChell',
'notification_type': 'email',
'groups_id': [(6, 0, [cls.env.ref('base.group_portal').id])]})
cls.user_projectuser = Users.create({
'name': 'Armande ProjectUser',
'login': 'Armande',
@@ -59,3 +80,12 @@ class TestProjectBase(TestMail):
'sequence': 10,
})]
})
def format_and_process(self, template, to='groups@example.com, other@gmail.com', subject='Frogs',
extra='', email_from='Sylvie Lelitre <test.sylvie.lelitre@agrolait.com>',
cc='', msg_id='<1198923581.41972151344608186760.JavaMail@agrolait.com>',
model=None, target_model='project.task', target_field='name'):
self.assertFalse(self.env[target_model].search([(target_field, '=', subject)]))
mail = template.format(to=to, subject=subject, cc=cc, extra=extra, email_from=email_from, msg_id=msg_id)
self.env['mail.thread'].with_context(mail_channel_noautofollow=True).message_process(model, mail)
return self.env[target_model].search([(target_field, '=', subject)])