Tests have been migrated to the new api to prepare the migration of the mail module itself. Moreover tests have been cleaned: redundant tests and unnecessary tests have been removed. As the base test class in mail is used in other addons, other addons have been updated : - portal - project - portal_project - website_project_issue - sale - purchase Future commits will come with somes fixes for issues detected when cleaning the tests.
30 lines
1.4 KiB
Python
30 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from openerp.addons.base.tests.test_ir_actions import TestServerActionsBase
|
|
|
|
|
|
class TestServerActionsEmail(TestServerActionsBase):
|
|
|
|
def test_00_state_email(self):
|
|
""" Test ir.actions.server email type """
|
|
# create email_template
|
|
email_template = self.env['mail.template'].create({
|
|
'name': 'TestTemplate',
|
|
'email_from': 'myself@example.com',
|
|
'email_to': 'brigitte@example.com',
|
|
'partner_to': '%s' % self.test_partner_id,
|
|
'model_id': self.res_partner_model_id,
|
|
'subject': 'About ${object.name}',
|
|
'body_html': '<p>Dear ${object.name}, your parent is ${object.parent_id and object.parent_id.name or "False"}</p>',
|
|
})
|
|
action = self.env['ir.actions.server'].browse(self.act_id)
|
|
action.write({'state': 'email', 'template_id': email_template.id})
|
|
run_res = action.with_context(self.context).run()
|
|
self.assertFalse(run_res, 'ir_actions_server: email server action correctly finished should return False')
|
|
# check an email is waiting for sending
|
|
mail = self.env['mail.mail'].search([('subject', '=', 'About TestingPartner')])
|
|
self.assertEqual(len(mail.ids), 1, 'ir_actions_server: TODO')
|
|
# check email content
|
|
self.assertEqual(mail.body, '<p>Dear TestingPartner, your parent is False</p>',
|
|
'ir_actions_server: TODO')
|