[PATCH] Upstream patch - 13022023

This commit is contained in:
Parthiv Patel
2023-02-13 08:34:33 +00:00
parent 0734be14dd
commit 04c9e038b3
+13 -8
View File
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from unittest.mock import patch
import flectra
from flectra.tests import HttpCase
from flectra import http
@@ -39,11 +42,13 @@ class TestAuthSignupFlow(HttpCase):
'csrf_token': csrf_token,
}
# Call the controller
url_free_signup = self._get_free_signup_url()
self.url_open(url_free_signup, data=payload)
# Check if an email is sent to the new user
new_user = self.env['res.users'].search([('name', '=', name)])
self.assertTrue(new_user)
mail = self.env['mail.message'].search([('message_type', '=', 'email'), ('model', '=', 'res.users'), ('res_id', '=', new_user.id)], limit=1)
self.assertTrue(mail, "The new user must be informed of his registration")
# Override unlink to not delete the email if the send works.
with patch.object(flectra.addons.mail.models.mail_mail.MailMail, 'unlink', lambda self: None):
# Call the controller
url_free_signup = self._get_free_signup_url()
self.url_open(url_free_signup, data=payload)
# Check if an email is sent to the new user
new_user = self.env['res.users'].search([('name', '=', name)])
self.assertTrue(new_user)
mail = self.env['mail.message'].search([('message_type', '=', 'email'), ('model', '=', 'res.users'), ('res_id', '=', new_user.id)], limit=1)
self.assertTrue(mail, "The new user must be informed of his registration")