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.

36 lines
1.3 KiB

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