-
-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de21a07
commit 63978b2
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import tests | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from odoo.tests import common | ||
from unittest import mock | ||
|
||
imp_requests = "odoo.addons.website_recaptcha_v2.models.website.requests" | ||
|
||
|
||
class TestModule(common.TransactionCase): | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.website = cls.env.ref("website.default_website") | ||
cls.website.write( | ||
{ | ||
"recaptcha_v2_enabled": True, | ||
"recaptcha_v2_site_key": "test-site", | ||
"recaptcha_v2_secret_key": "test-secret", | ||
} | ||
) | ||
|
||
@mock.patch(imp_requests) | ||
def test_captcha_valid(self, requests_mock): | ||
requests_mock.post().json.return_value = {"success": True} | ||
result, error_msg = self.website.is_recaptcha_v2_valid( | ||
{"g-recaptcha-response": "dummy_response"} | ||
) | ||
self.assertTrue(result) | ||
self.assertEqual(error_msg, "") |