diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-07-15 17:25:16 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-07-15 17:25:16 +0200 |
| commit | 8aeba8a3a34b60f15cb9fe19ad67a49e7882f8ae (patch) | |
| tree | 69dc943190fbebec2530d897c5542344327f0efa /addons/email_template/tests | |
| parent | a81df9ca2b9cd8536d51b1d8b0a4be104b997244 (diff) | |
[ADD] email_template: added support for 'email' server action.
Email server action are now entirely based on templates.
Added tests.
bzr revid: tde@openerp.com-20130715152516-69gokja8u0afgfh8
Diffstat (limited to 'addons/email_template/tests')
| -rw-r--r-- | addons/email_template/tests/__init__.py | 3 | ||||
| -rw-r--r-- | addons/email_template/tests/test_ir_actions.py | 55 |
2 files changed, 57 insertions, 1 deletions
diff --git a/addons/email_template/tests/__init__.py b/addons/email_template/tests/__init__.py index d63c5634cc3..9418985b06c 100644 --- a/addons/email_template/tests/__init__.py +++ b/addons/email_template/tests/__init__.py @@ -18,10 +18,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -from . import test_mail +from . import test_mail, test_ir_actions checks = [ test_mail, + test_ir_actions, ] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/addons/email_template/tests/test_ir_actions.py b/addons/email_template/tests/test_ir_actions.py new file mode 100644 index 00000000000..d323ee36c1f --- /dev/null +++ b/addons/email_template/tests/test_ir_actions.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +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 """ + cr, uid = self.cr, self.uid + + # create email_template + template_id = self.registry('email.template').create(cr, uid, { + '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>', + }) + + self.ir_actions_server.write(cr, uid, self.act_id, { + 'state': 'email', + 'template_id': template_id, + }) + run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) + self.assertFalse(run_res, 'ir_actions_server: email server action correctly finished should return False') + + # check an email is waiting for sending + mail_ids = self.registry('mail.mail').search(cr, uid, [('subject', '=', 'About TestingPartner')]) + self.assertEqual(len(mail_ids), 1, 'ir_actions_server: TODO') + # check email content + mail = self.registry('mail.mail').browse(cr, uid, mail_ids[0]) + self.assertEqual(mail.body, '<p>Dear TestingPartner, your parent is False</p>', + 'ir_actions_server: TODO') |
