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.

56 lines
2.1 KiB

  1. # Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
  2. # Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
  3. # License MIT (https://opensource.org/licenses/MIT).
  4. from odoo.tools import mute_logger
  5. from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE
  6. from odoo.addons.test_mail.tests.test_mail_mail import TestMail
  7. class TestFetch(TestMail):
  8. at_install = True
  9. post_install = True
  10. def setUp(self):
  11. super(TestFetch, self).setUp()
  12. self.website = self.env["website"].create(
  13. {"name": "Test Website", "domain": "example.com"}
  14. )
  15. self.company = self.env["res.company"].create({"name": "New Test Website"})
  16. self.website.company_id = self.company
  17. # copy-paste from mail.tests.test_mail_gateway
  18. mail_test_model = self.env["ir.model"]._get("mail.test.simple")
  19. # groups@.. will cause the creation of new mail.test
  20. self.alias = self.env["mail.alias"].create(
  21. {
  22. "alias_name": "groups",
  23. "alias_user_id": False,
  24. "alias_model_id": mail_test_model.id,
  25. "alias_contact": "everyone",
  26. }
  27. )
  28. @mute_logger("odoo.addons.mail.models.mail_thread", "odoo.models")
  29. def test_fetch_multi_website(self):
  30. """ Incoming email on an alias creating a new record + message_new + message details """
  31. new_groups = self.format_and_process(
  32. MAIL_TEMPLATE, subject="My Frogs", to="groups@example.com, other@gmail.com"
  33. )
  34. # Test: one group created by mailgateway administrator
  35. self.assertEqual(
  36. len(new_groups),
  37. 1,
  38. "message_process: a new mail.test should have been created",
  39. )
  40. self.assertEqual(
  41. new_groups.website_id,
  42. self.website,
  43. "New record is created with wrong website",
  44. )
  45. self.assertEqual(
  46. new_groups.company_id,
  47. self.company,
  48. "New record is created with wrong company",
  49. )