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.0 KiB

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