From 0892923bcff081b2545731cee04da31ada5ec907 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 13 Jul 2023 13:31:06 +0000 Subject: [PATCH] [FIX] mass_mailing: test_mailing_controller Add a handler for the fake URL we track, otherwise after visiting the short URL we get redirected and the request blows up. Part-of: odoo/odoo#128497 --- addons/mass_mailing/tests/test_mailing_controllers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/mass_mailing/tests/test_mailing_controllers.py b/addons/mass_mailing/tests/test_mailing_controllers.py index 14000b65947..a7777616ab8 100644 --- a/addons/mass_mailing/tests/test_mailing_controllers.py +++ b/addons/mass_mailing/tests/test_mailing_controllers.py @@ -7,6 +7,8 @@ import datetime import werkzeug from odoo.addons.mass_mailing.tests.common import MassMailCommon +from requests import Session, PreparedRequest, Response + from odoo.tests.common import HttpCase from odoo.tests import tagged @@ -33,6 +35,13 @@ class TestMailingControllers(MassMailCommon, HttpCase): # freeze time base value cls._reference_now = datetime.datetime(2022, 6, 14, 10, 0, 0) + def _request_handler(self, s: Session, r: PreparedRequest, /, **kw): + if r.url.startswith('https://www.example.com/foo/bar'): + r = Response() + r.status_code = 200 + return r + return super()._request_handler(s, r, **kw) + def test_tracking_short_code(self): """ Test opening short code linked to a mailing trace: should set the trace as opened and clicked, create a click record. """