From ff66035b26031134506fffe3f29e9fd922160397 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Tue, 18 Apr 2023 07:02:48 +0000 Subject: [PATCH] [IMP] website_mass_mailing: improve the newsletter block test Prior to this commit, starting this test individually would not work as the admin user is subscribed to the mailing list used during the test. The reason the test has passed our test suite is because on runbot the `mass_mailing_sms` module is installed, which adds a new mailing list to which the admin user is not subscribed. This commit changes the test to always ensure that the admin is not subscribed to any newsletter, making the test a bit more robust. closes odoo/odoo#121200 X-original-commit: f7465d0f13236518ee79e43e65222d0ca0c0b0fb Signed-off-by: Outagant Mehdi (mou) --- addons/website_mass_mailing/tests/test_snippets.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/website_mass_mailing/tests/test_snippets.py b/addons/website_mass_mailing/tests/test_snippets.py index 311674b0fcf..1f638c8a051 100644 --- a/addons/website_mass_mailing/tests/test_snippets.py +++ b/addons/website_mass_mailing/tests/test_snippets.py @@ -16,4 +16,13 @@ class TestSnippets(odoo.tests.HttpCase): self.assertIn("hello@world.com", emails) def test_02_newsletter_block_edition(self): + admin_email = self.env.ref('base.user_admin').email + # Get contacts with this email + mass_mailing_contacts = self.env['mailing.contact'].search([('email', '=', admin_email)]) + mailing_list = self.env['mailing.list'].search([('contact_ids', 'in', mass_mailing_contacts.ids)]) + # Unsubscribe the admin's email from every mailing list to ensure the + # tour can subscribe the admin again + mailing_list.write({ + 'contact_ids': [odoo.Command.unlink(id) for id in mass_mailing_contacts.ids] + }) self.start_tour(self.env['website'].get_client_action_url('/'), 'newsletter_block_edition', login='admin')