common.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import Command, tools
  4. from odoo.addons.mail.tests.common import mail_new_test_user
  5. from odoo.addons.test_mail.tests.common import TestMailCommon
  6. class TestMailListCommon(TestMailCommon):
  7. @classmethod
  8. def setUpClass(cls):
  9. super(TestMailListCommon, cls).setUpClass()
  10. # Test credentials / from
  11. cls.email_from_unknown = tools.formataddr(("Bob Lafrite", "bob.email@test.example.com"))
  12. cls.user_employee_2 = mail_new_test_user(
  13. cls.env, login='employee_2',
  14. company_id=cls.company_admin.id,
  15. email='employee_2@test.com',
  16. groups='base.group_user',
  17. name='Albertine Another Employee',
  18. )
  19. # Test group: members, moderation
  20. cls.test_group = cls.env['mail.group'].create({
  21. 'access_mode': 'public',
  22. 'alias_name': 'test.mail.group',
  23. 'moderation': True,
  24. 'moderator_ids': [Command.link(cls.user_employee.id)],
  25. 'name': 'Test group',
  26. })
  27. cls.moderation = cls.env['mail.group.moderation'].create({
  28. 'mail_group_id': cls.test_group.id,
  29. 'email': 'banned_member@test.com',
  30. 'status': 'ban',
  31. })
  32. cls.test_group_member_1 = cls.env['mail.group.member'].create({
  33. 'email': '"Member 1" <member_1@test.com>',
  34. 'mail_group_id': cls.test_group.id,
  35. })
  36. cls.test_group_member_2 = cls.env['mail.group.member'].create({
  37. 'email': 'member_2@test.com',
  38. 'mail_group_id': cls.test_group.id,
  39. })
  40. cls.test_group_member_3_banned = cls.env['mail.group.member'].create({
  41. 'email': '"Banned Member" <banned_member@test.com>',
  42. 'mail_group_id': cls.test_group.id,
  43. })
  44. cls.test_group_member_4_emp = cls.env['mail.group.member'].create({
  45. 'partner_id': cls.partner_employee.id,
  46. 'mail_group_id': cls.test_group.id,
  47. })
  48. cls.test_group_valid_members = cls.test_group_member_1 + cls.test_group_member_2 + cls.test_group_member_4_emp
  49. cls._init_mail_gateway()
  50. # Create some messages
  51. cls.test_group_msg_1_pending = cls.env['mail.group.message'].create({
  52. 'subject': 'Test message pending',
  53. 'mail_group_id': cls.test_group.id,
  54. 'moderation_status': 'pending_moderation',
  55. 'email_from': '"Bob" <bob@test.com>',
  56. })
  57. cls.test_group_msg_2_accepted = cls.env['mail.group.message'].create({
  58. 'subject': 'Test message accepted',
  59. 'mail_group_id': cls.test_group.id,
  60. 'moderation_status': 'accepted',
  61. 'email_from': '"Alice" <alice@test.com>',
  62. })
  63. cls.test_group_msg_3_rejected = cls.env['mail.group.message'].create({
  64. 'subject': 'Test message rejected',
  65. 'mail_group_id': cls.test_group.id,
  66. 'moderation_status': 'rejected',
  67. 'email_from': '"Alice" <alice@test.com>',
  68. })
  69. cls.user_portal = cls._create_portal_user()