You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. class TestMailNotificationEmailTemplate(TransactionCase):
  6. def test_mail_notification_email_template(self):
  7. # we install a template for discussions, so we simply post
  8. # something somewhere. We know the demo user is subscribed on the
  9. # whole company group
  10. demo_partner = self.env.ref('base.partner_demo')
  11. demo_partner.write({'notify_email': 'always'})
  12. demo_partner_mails = self.env['mail.mail'].search([
  13. ('recipient_ids', '=', demo_partner.id),
  14. ])
  15. self.env.ref('mail.group_all_employees').message_post(
  16. body='hello world', type='comment', subtype='mail.mt_comment')
  17. notifications = self.env['mail.mail'].search([
  18. ('recipient_ids', '=', demo_partner.id),
  19. ]) - demo_partner_mails
  20. self.assertTrue(notifications)
  21. # check that our template was used
  22. self.assertTrue('<h2>Dear ' in n.body for n in notifications)