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.

37 lines
1.3 KiB

  1. # Copyright 2017-2018 Tecnativa - Pedro M. Baeza
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests import common
  4. from odoo import exceptions
  5. class TestMassMailingResend(common.SavepointCase):
  6. @classmethod
  7. def setUpClass(cls):
  8. super(TestMassMailingResend, cls).setUpClass()
  9. cls.list = cls.env['mail.mass_mailing.list'].create({
  10. 'name': 'Test list',
  11. })
  12. cls.contact1 = cls.env['mail.mass_mailing.contact'].create({
  13. 'name': 'Contact 1',
  14. 'email': 'email1@test.com',
  15. })
  16. cls.mass_mailing = cls.env['mail.mass_mailing'].create({
  17. 'name': 'Test mass mailing',
  18. 'email_from': 'test@example.org',
  19. 'mailing_model_id': cls.env.ref(
  20. 'mass_mailing.model_mail_mass_mailing_contact'
  21. ).id,
  22. 'contact_list_ids': [(6, 0, cls.list.ids)],
  23. 'reply_to_mode': 'thread',
  24. })
  25. def test_resend_error(self):
  26. with self.assertRaises(exceptions.UserError):
  27. self.mass_mailing.button_draft()
  28. def test_resend(self):
  29. self.mass_mailing.state = 'done' # Force state
  30. self.assertEqual(self.mass_mailing.state, 'done')
  31. self.mass_mailing.button_draft()
  32. self.assertEqual(self.mass_mailing.state, 'draft')