From 5a37fbc6cb0a3f74b09ea7432a5be5f454082533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Tue, 28 Mar 2023 09:30:44 +0000 Subject: [PATCH] [FIX] mail: fix user preference test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit mocks the "preference_save" action on the res.users model during the test that checks that the user can modify its own preferences. This allows to ease the testing as a context reload in the middle of test steps was not handled correctly by the test runner. Task-3246086 closes odoo/odoo#116800 Signed-off-by: Xavier Dollé (xdo) --- addons/mail/tests/test_user_modify_own_profile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/mail/tests/test_user_modify_own_profile.py b/addons/mail/tests/test_user_modify_own_profile.py index 3477cd9bfa5..7d3e7846ed4 100644 --- a/addons/mail/tests/test_user_modify_own_profile.py +++ b/addons/mail/tests/test_user_modify_own_profile.py @@ -2,6 +2,9 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.tests import HttpCase, tagged +from odoo.addons.base.models.res_users import Users + +from unittest.mock import patch @tagged('-at_install', 'post_install') @@ -11,5 +14,7 @@ class TestUserModifyOwnProfile(HttpCase): """" A user should be able to modify their own profile. Even if that user does not have access rights to write on the res.users model. """ - self.start_tour("/web", "mail/static/tests/tours/user_modify_own_profile_tour.js", login="demo") + # avoid 'reload_context' action in the middle of the tour to ease steps and form save checks + with patch.object(Users, 'preference_save', lambda self: True): + self.start_tour("/web", "mail/static/tests/tours/user_modify_own_profile_tour.js", login="demo") self.assertEqual(self.env.ref('base.user_demo').email, "updatedemail@example.com")