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.

41 lines
1.8 KiB

  1. # Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. from odoo.addons.mail.tests.common import TestMail
  4. from odoo.tools import mute_logger
  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',
  13. 'domain': 'example.com',
  14. })
  15. self.company = self.env['res.company'].create({
  16. 'name': 'New Test Website'
  17. })
  18. self.website.company_id = self.company
  19. # copy-paste from mail.tests.test_mail_gateway
  20. mail_test_model = self.env['ir.model']._get('mail.test')
  21. # groups@.. will cause the creation of new mail.test
  22. self.alias = self.env['mail.alias'].create({
  23. 'alias_name': 'groups',
  24. 'alias_user_id': False,
  25. 'alias_model_id': mail_test_model.id,
  26. 'alias_contact': 'everyone'})
  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(MAIL_TEMPLATE, subject='My Frogs', to='groups@example.com, other@gmail.com')
  31. # Test: one group created by mailgateway administrator
  32. self.assertEqual(len(new_groups), 1, 'message_process: a new mail.test should have been created')
  33. self.assertEqual(new_groups.website_id, self.website, 'New record is created with wrong website')
  34. self.assertEqual(new_groups.company_id, self.company, 'New record is created with wrong company')