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.

64 lines
2.0 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # -*- coding: utf-8 -*-
  2. from openerp.tests.common import TransactionCase
  3. class TestMessageCount(TransactionCase):
  4. post_install = True
  5. def test_count(self):
  6. new_partner1 = (
  7. self.env["res.partner"]
  8. .sudo()
  9. .create(
  10. {
  11. "name": "rpmc Test Partner one",
  12. "email": "tt@tt",
  13. "notify_email": "always",
  14. }
  15. )
  16. )
  17. new_partner2 = (
  18. self.env["res.partner"]
  19. .sudo()
  20. .create(
  21. {
  22. "name": "rpmc Test Partner two",
  23. "email": "rr@rr",
  24. "notify_email": "always",
  25. }
  26. )
  27. )
  28. self.assertEqual(
  29. new_partner1.mails_to, 0, "rpmc: new partner have mails_to != 0"
  30. )
  31. mail_compose = self.env["mail.compose.message"]
  32. compose = mail_compose.with_context(
  33. {"default_composition_mode": "comment"}
  34. ).create(
  35. {
  36. "subject": "test subj",
  37. "body": "test body",
  38. "partner_ids": [(4, new_partner2.id)],
  39. "email_from": "tt@tt",
  40. "author_id": new_partner1.id,
  41. }
  42. )
  43. compose.send_mail()
  44. self.assertEqual(new_partner1.mails_to, 0)
  45. self.assertEqual(
  46. new_partner1.mails_from, 1, "rpmc: one message but mails_from != 1"
  47. )
  48. self.assertEqual(
  49. new_partner2.mails_to, 1, "rpmc: one message but mails_to != 1"
  50. )
  51. self.assertEqual(new_partner2.mails_from, 0)
  52. compose.send_mail()
  53. self.assertEqual(new_partner1.mails_to, 0)
  54. self.assertEqual(
  55. new_partner1.mails_from, 2, "rpmc: one message but mails_from != 2"
  56. )
  57. self.assertEqual(
  58. new_partner2.mails_to, 2, "rpmc: one message but mails_to != 2"
  59. )
  60. self.assertEqual(new_partner2.mails_from, 0)