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.

37 lines
1.6 KiB

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