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.

38 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Tecnativa - Pedro M. Baeza
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests import common
  5. class TestSignatureTracking(common.SavepointCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super(TestSignatureTracking, cls).setUpClass()
  9. cls.user = cls.env['res.users'].create({
  10. 'name': 'Test User',
  11. 'login': 'Test User',
  12. 'email': 'test@example.com',
  13. })
  14. cls.user.lang = 'en_US'
  15. # Simple 1x1 transparent base64 encoded GIF
  16. cls.image = 'R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
  17. cls.attachment_obj = cls.env['ir.attachment']
  18. cls.message_obj = cls.env['mail.message']
  19. def test_signature_tracking(self):
  20. """We have to test in a tricky way, as res.users doesn't allow a
  21. direct chatter"""
  22. prev_attachment_num = self.attachment_obj.search_count([])
  23. prev_messages = self.message_obj.search([])
  24. self.user.signature_image = self.image
  25. current_attachment_num = self.attachment_obj.search_count([])
  26. self.assertEqual(current_attachment_num - prev_attachment_num, 1)
  27. current_messages = self.message_obj.search([])
  28. message = current_messages - prev_messages
  29. self.assertIn('Signature has been created.', message.body)
  30. prev_messages = current_messages
  31. self.user.signature_image = False
  32. current_messages = self.message_obj.search([])
  33. message = current_messages - prev_messages
  34. self.assertIn('Signature has been deleted.', message.body)