[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) <mou@odoo.com>
This commit is contained in:
Arthur Detroux (ard)
2023-05-15 15:07:22 +02:00
parent 859b17e3fc
commit ff66035b26
@@ -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')