def test_render_uses_language(self, render_to_string, activate_en): client = HumanCaptchaClient() client.render({'lang': 'de'}, 'foo bar') assert render_to_string.called_once_with( 'captcha/widget.html', { 'api_server': '//www.google.com/recaptcha/api', 'public_key': 'pubkey', 'lang': 'de', 'options': '{"lang": "de"}', 'challenge_url': '//www.google.com/recaptcha/api/challenge?k=pubkey&hl=de&error=foo%20bar', # noqa 'noscript_url': '//www.google.com/recaptcha/api/noscript?k=pubkey&hl=de&error=foo%20bar', # noqa } )
def test_verify_sucess(self): args = urlencode(self.verify_data) httpretty.register_uri( httpretty.GET, 'https://www.google.com/recaptcha/api/siteverify?' + args, body='{"error-codes": [], "success": true}', status=200, content_type='plain/text') client = HumanCaptchaClient() response = client.verify('test', 'test', '127.0.0.1') last_request = httpretty.last_request() assert last_request.path.startswith('/recaptcha/api/siteverify') assert response.is_valid
def test_verify_sucess(self): args = urlencode(self.verify_data) httpretty.register_uri( httpretty.GET, 'https://www.google.com/recaptcha/api/siteverify?' + args, body='', status=200, content_type='plain/text' ) client = HumanCaptchaClient() response = client.verify('test', 'test', '127.0.0.1') last_request = httpretty.last_request() assert last_request.path.startswith('/recaptcha/api/siteverify') assert response.is_valid
def test_render_simple(self, render_to_string, activate_en): client = HumanCaptchaClient() assert client.nocaptcha client.render({}) assert render_to_string.called_once_with( 'captcha/widget.html', { 'api_server': '//www.google.com/recaptcha/api', 'public_key': 'pubkey', 'lang': 'en', 'options': '{"lang": "en"}', 'challenge_url': '//www.google.com/recaptcha/api/challenge?k=pubkey&hl=en', # noqa 'noscript_url': '//www.google.com/recaptcha/api/noscript?k=pubkey&hl=en', # noqa } )
def test_render_uses_language(self, render_to_string, activate_en): client = HumanCaptchaClient() client.render({'lang': 'de'}, 'foo bar') render_to_string.assert_called_once_with( 'captcha/widget_nocaptcha.html', { 'api_server': '//www.google.com/recaptcha/api', 'public_key': 'pubkey', 'lang': 'de', 'options': '{"lang": "de"}', 'challenge_url': '//www.google.com/recaptcha/api/challenge?k=pubkey&hl=de&error=foo+bar', # noqa 'noscript_url': '//www.google.com/recaptcha/api/noscript?k=pubkey&hl=de&error=foo+bar', # noqa })
def test_render_simple(self, render_to_string, activate_en): client = HumanCaptchaClient() assert client.nocaptcha client.render({}) render_to_string.assert_called_once_with( 'captcha/widget_nocaptcha.html', { 'api_server': '//www.google.com/recaptcha/api', 'public_key': 'pubkey', 'lang': 'en', 'options': '{"lang": "en"}', 'challenge_url': '//www.google.com/recaptcha/api/challenge?k=pubkey&hl=en', # noqa 'noscript_url': '//www.google.com/recaptcha/api/noscript?k=pubkey&hl=en', # noqa })