Skip to content

Commit

Permalink
tests: Ensuring the email is not sent due to invalid reCAPTCHA
Browse files Browse the repository at this point in the history
Add g_recaptcha_response to the assert_in
  • Loading branch information
kovalch committed Jul 2, 2024
1 parent 00bb7eb commit 3b37af1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ckanext/subscribe/tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,28 @@ def test_verify_recaptcha_failure(

dataset = factories.Dataset()

# Attempting to call subscribe_signup action with a None reCAPTCHA
with assert_raises(ValidationError) as cm:
# Attempting to call subscribe_signup action with an invalid reCAPTCHA
try:
helpers.call_action(
"subscribe_signup",
{},
email="bob@example.com",
dataset_id=dataset["id"],
g_recaptcha_response="invalid-recaptcha-response",
)
except ValidationError as cm:
# Asserting that the error is raised due to invalid reCAPTCHA
assert_in(
'Invalid reCAPTCHA response: "g_recaptcha_response"',
str(cm.exception.error_dict),
)

assert_in(
"Invalid reCAPTCHA. Please try again.",
str(cm.exception.error_dict),
)
assert not send_request_email.called

assert not send_request_email.called
# Ensuring the email is not sent due to invalid reCAPTCHA
assert not send_request_email.called
else:
assert False, "ValidationError not raised"


class TestSubscribeVerify(object):
Expand Down

0 comments on commit 3b37af1

Please sign in to comment.