def test_abuse_http_err(self): ag = AntiCaptcha(api_key, loop=self.loop) ag.close() ag._session = fake_client_session(400, 'OK') with self.assertRaises(ServiceError) as cm: self.loop.run_until_complete(ag.abuse(123)) self.assertIn('HTTP error', str(cm.exception))
def test_abuse_handle_error(self): ag = AntiCaptcha(api_key, loop=self.loop) ag.close() ag._session = fake_client_session(200, 'ERROR_NO_REQUEST_ACTION_RECEIVED') with self.assertRaises(ServiceError) as cm: self.loop.run_until_complete(ag.abuse(123)) self.assertIn('No request action received', str(cm.exception))
def test_abuse_client_error(self): ag = AntiCaptcha(api_key, loop=self.loop) ag.close() ag._session, resp = fake_client_session(200, aiohttp.ClientError(), ret_resp=True) with self.assertRaises(ServiceError) as cm: self.loop.run_until_complete(ag.abuse(123)) self.assertIn('Network error', str(cm.exception)) self.assertTrue(resp.release.called) self.assertTrue(resp.close.called)