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.

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