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.

45 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 ACSONE SA/NV <https://acsone.eu>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import openerp.tests.common as common
  5. class TestMailNotification(common.TransactionCase):
  6. def setUp(self):
  7. super(TestMailNotification, self).setUp()
  8. self.mail_notification_obj = self.env['mail.notification']
  9. self.partner_obj = self.env['res.partner']
  10. self.registry('ir.model').clear_caches()
  11. self.registry('ir.model.data').clear_caches()
  12. def test_get_signature_footer(self):
  13. vals = {
  14. 'name': 'p1@exemple.com',
  15. 'notify_email': 'none',
  16. }
  17. partner1 = self.partner_obj.create(vals)
  18. vals = {
  19. 'name': 'p2@exemple.com',
  20. 'notify_email': 'always',
  21. }
  22. partner2 = self.partner_obj.create(vals)
  23. footer = self.mail_notification_obj.get_signature_footer(self.env.uid)
  24. self.assertFalse(
  25. partner1.name in footer or partner2.name in footer,
  26. 'Standard behavior does not add notified partners into the footer')
  27. footer = self.mail_notification_obj.with_context(
  28. partners_to_notify=[partner1.id, partner2.id]
  29. ).get_signature_footer(self.env.uid)
  30. self.assertFalse(
  31. partner1.name in footer,
  32. 'Partner with "notify_email: "none" should not be into the footer')
  33. self.assertTrue(
  34. partner2.name in footer,
  35. 'Partner with "notify_email: "always" should be into the footer')