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