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.

34 lines
1.4 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.user
  10. cls.user.lang = 'en_US'
  11. # Simple 1x1 transparent base64 encoded GIF
  12. cls.image = 'R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
  13. cls.attachment_obj = cls.env['ir.attachment']
  14. cls.message_obj = cls.env['mail.message']
  15. def test_signature_tracking(self):
  16. """We have to test in a tricky way, as res.users doesn't allow a
  17. direct chatter"""
  18. prev_attachment_num = self.attachment_obj.search_count([])
  19. prev_messages = self.message_obj.search([])
  20. self.user.signature = self.image
  21. current_attachment_num = self.attachment_obj.search_count([])
  22. self.assertEqual(current_attachment_num - prev_attachment_num, 1)
  23. current_messages = self.message_obj.search([])
  24. message = current_messages - prev_messages
  25. self.assertIn('Signature has been created.', message.body)
  26. prev_messages = current_messages
  27. self.user.signature = False
  28. current_messages = self.message_obj.search([])
  29. message = current_messages - prev_messages
  30. self.assertIn('Signature has been deleted.', message.body)