Skip to content

Commit

Permalink
[ADD]Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edescalona committed Dec 2, 2024
1 parent de21a07 commit 63978b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions website_recaptcha_v2_login/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import tests
from . import models
from . import controllers
26 changes: 26 additions & 0 deletions website_recaptcha_v2_login/tests/test_recaptcha.py
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, "")

0 comments on commit 63978b2

Please sign in to comment.