diff --git a/website_recaptcha_v2_login/tests/test_recaptcha.py b/website_recaptcha_v2_login/tests/test_recaptcha.py index 9059537668..4ee5327519 100644 --- a/website_recaptcha_v2_login/tests/test_recaptcha.py +++ b/website_recaptcha_v2_login/tests/test_recaptcha.py @@ -1,5 +1,6 @@ from unittest import mock +from odoo.exceptions import AccessDenied from odoo.tests import common imp_requests = "odoo.addons.website_recaptcha_v2.models.website.requests" @@ -25,3 +26,9 @@ def test_captcha_valid(self, requests_mock): {"g-recaptcha-response": "dummy_response"} ) self.assertTrue(result) + + @mock.patch(imp_requests) + def test_captcha_not_valid(self, requests_mock): + requests_mock.post().json.return_value = {"success": False} + with self.assertRaises(AccessDenied): + self.website.valid_recaptcha({"g-recaptcha-response": ""})