def test_parse_response_bad_response_param(self): """ Can parse response correctly """ client = RecaptchaClient() success, msg = client._parse_response('response') self.assertFalse(success) self.assertEqual(msg, '')
def test_parse_response_successful_challenge(self): """ Can parse a successful challenge """ client = RecaptchaClient() request = httpclient.HTTPRequest('http://someurl.com') response = httpclient.HTTPResponse(request, 200, buffer=StringIO('true\notherstuff')) success, msg = client._parse_response(response) self.assertTrue(success) self.assertEqual(msg, '')
def test_parse_response_with_error_response(self): """ test calling with an error response """ client = RecaptchaClient() request = httpclient.HTTPRequest('http://someurl.com') response = httpclient.HTTPResponse(request, 404) success, msg = client._parse_response(response) self.assertFalse(success) self.assertEqual(msg, '')
def test_parse_response_failure(self): """ Can parse a failed challenge """ client = RecaptchaClient() request = httpclient.HTTPRequest('http://someurl.com') response = httpclient.HTTPResponse(request, 200, buffer=StringIO('false\nincorrect-captcha-sol')) success, msg = client._parse_response(response) self.assertFalse(success) self.assertEqual(msg, 'incorrect-captcha-sol')