@pytest.mark.parametrize(('validator_class', 'params', 'response', 'error'), [(ReCaptchaV2Validator, {}, RecaptchaResponse(is_valid=False), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV2Validator, {}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.6, 'action': 'test_action'}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_error')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=False), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_error')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.3}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.5}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.5, 'action': 'other_action'}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]")])
def test_recaptcha_validator_call_fail(validator_class, params, response, error):
    validator = validator_class(**params)
    validator.get_response = mock.Mock(return_value=response)
    with pytest.raises(ValidationError) as exc_info:
        validator('test_token')
    assert (str(exc_info.value) == error)
@pytest.mark.parametrize(('validator_class', 'params', 'response', 'error'), [(ReCaptchaV2Validator, {}, RecaptchaResponse(is_valid=False), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV2Validator, {}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.6, 'action': 'test_action'}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_error')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=False), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_error')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.3}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.5}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]"), (ReCaptchaV3Validator, {'action': 'test_action', 'required_score': 0.4}, RecaptchaResponse(is_valid=True, extra_data={'score': 0.5, 'action': 'other_action'}), "[ErrorDetail(string='Error verifying reCAPTCHA, please try again.', code='captcha_invalid')]")])
def test_recaptcha_validator_call_fail(validator_class, params, response, error):
    validator = validator_class(**params)
    validator.get_response = mock.Mock(return_value=response)
    with pytest.raises(ValidationError) as exc_info:
        validator('test_token')
    assert (str(exc_info.value) == error)