From 1f4df8efb043e68450b0522246b2bfed18688f5f Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 7 Oct 2019 00:55:09 +0300 Subject: [PATCH] Update version Fix old tests --- setup.py | 2 +- test.py | 511 +------------------------------------------------------ 2 files changed, 2 insertions(+), 511 deletions(-) diff --git a/setup.py b/setup.py index 7be6193..a0e5085 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ EMAIL = "drang.andray@gmail.com" AUTHOR = "AndreiDrang, redV0ID" REQUIRES_PYTHON = ">=3.6.0" -VERSION = "1.5.2" +VERSION = "1.5.4" REQUIRED = ["requests==2.22.0", "aiohttp==3.6.1", "pika==1.1.0"] here = os.path.abspath(os.path.dirname(__file__)) diff --git a/test.py b/test.py index e037617..03ba5fe 100644 --- a/test.py +++ b/test.py @@ -8,7 +8,6 @@ from python3_anticaptcha import ( NoCaptchaTaskProxyless, - AntiCaptchaControl, ReCaptchaV3TaskProxyless, ) @@ -272,512 +271,4 @@ def test_fail_aiorecaptcha_v3_proxyless_context(self): pageAction="login_test", ) - """ - Control - """ - - def test_control_type(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # check response type - assert type(result) is AntiCaptchaControl.AntiCaptchaControl - - def test_control_params(self): - default_init_params = ["self", "anticaptcha_key"] - default_balance_params = ["self"] - default_complaint_params = ["self", "reported_id", "captcha_type"] - default_queue_status_params = ["self", "queue_id"] - # get customcaptcha init and other params - aioinit_params = inspect.getfullargspec( - AntiCaptchaControl.aioAntiCaptchaControl.__init__ - ) - aiobalance_params = inspect.getfullargspec( - AntiCaptchaControl.aioAntiCaptchaControl.get_balance - ) - aiocomplaint_params = inspect.getfullargspec( - AntiCaptchaControl.aioAntiCaptchaControl.complaint_on_result - ) - aioqueue_status_params = inspect.getfullargspec( - AntiCaptchaControl.aioAntiCaptchaControl.get_queue_status - ) - - # get customcaptcha init and other params - init_params = inspect.getfullargspec( - AntiCaptchaControl.AntiCaptchaControl.__init__ - ) - balance_params = inspect.getfullargspec( - AntiCaptchaControl.AntiCaptchaControl.get_balance - ) - complaint_params = inspect.getfullargspec( - AntiCaptchaControl.AntiCaptchaControl.complaint_on_result - ) - queue_status_params = inspect.getfullargspec( - AntiCaptchaControl.AntiCaptchaControl.get_queue_status - ) - # check aio module params - assert default_init_params == aioinit_params[0] - assert default_balance_params == aiobalance_params[0] - assert default_complaint_params == aiocomplaint_params[0] - assert default_queue_status_params == aioqueue_status_params[0] - # check sync module params - assert default_init_params == init_params[0] - assert default_balance_params == balance_params[0] - assert default_complaint_params == complaint_params[0] - assert default_queue_status_params == queue_status_params[0] - - # AntiCaptcha Control - def test_fail_queue_status(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - q_id = self.WRONG_QUEUE_ID - - with pytest.raises(ValueError): - # get queue status - assert result.get_queue_status(queue_id=q_id) - - # AntiCaptcha Control - def test_true_queue_status(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - q_id = random.choice(AntiCaptchaControl.queue_ids) - for q_id in AntiCaptchaControl.queue_ids: - # get queue status - response = result.get_queue_status(queue_id=q_id) - # check response type - assert type(response) is dict - # check all dict keys - assert ["waiting", "load", "bid", "speed", "total"] == list(response.keys()) - - # AntiCaptcha Control - def test_fail_balance(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # get balance - response = result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - # AntiCaptcha Control - def test_fail_app_stats(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # get balance - response = result.get_app_stats(softId=867) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - with pytest.raises(ValueError): - assert result.get_app_stats(softId=867, mode="filure") - - # AntiCaptcha Control - def test_fail_complaint_on_result(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # complaint on result - response = result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - with pytest.raises(ValueError): - assert result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="not_image" - ) - - # AntiCaptcha Control - def test_true_balance(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # get balance - response = result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "balance"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # AntiCaptcha Control - def test_true_complaint_on_result(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # complaint on result - response = result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="image" - ) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 - - # complaint on result - response = result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="recaptcha" - ) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 - - def test_fail_control_context(self): - # prepare client - with AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) as result: - # get balance - response = result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - - # complaint on result - response = result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - # AntiCaptcha Control - def test_true_app_stats(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # get balance - response = result.get_app_stats(softId=867) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = result.get_app_stats(softId=867, mode="errors") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = result.get_app_stats(softId=867, mode="views") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = result.get_app_stats(softId=867, mode="downloads") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = result.get_app_stats(softId=867, mode="users") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = result.get_app_stats(softId=867, mode="money") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - def test_true_control_context(self): - # prepare client - with AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) as result: - # get balance - response = result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "balance"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # complaint on result - response = result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 - - # AntiCaptcha Control - @asyncio.coroutine - def test_fail_aioqueue_status(self): - # prepare client - result = AntiCaptchaControl.AntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - q_id = self.WRONG_QUEUE_ID - - with pytest.raises(ValueError): - # get queue status - assert result.get_queue_status(queue_id=q_id) - - # AntiCaptcha Control - @asyncio.coroutine - def test_true_aioqueue_status(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - q_id = random.choice(AntiCaptchaControl.queue_ids) - for q_id in AntiCaptchaControl.queue_ids: - # get queue status - response = yield result.get_queue_status(queue_id=q_id) - # check response type - assert type(response) is dict - # check all dict keys - assert ["waiting", "load", "bid", "speed", "total"] == list(response.keys()) - - @asyncio.coroutine - def test_fail_aiobalance(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # get balance - response = yield result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - - @asyncio.coroutine - def test_fail_aiocomplaint_on_result(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # complaint on result - response = yield result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - with pytest.raises(ValueError): - assert result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="not_image" - ) - - @asyncio.coroutine - def test_fail_aioapp_stats(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) - # complaint on result - response = yield result.get_app_stats(softId=867) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - with pytest.raises(ValueError): - assert result.get_app_stats(softId=867, mode="filure") - - @asyncio.coroutine - def test_true_aioapp_stats(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # complaint on result - response = yield result.get_app_stats(softId=867) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = yield result.get_app_stats(softId=867, mode="errors") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = yield result.get_app_stats(softId=867, mode="views") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = yield result.get_app_stats(softId=867, mode="downloads") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = yield result.get_app_stats(softId=867, mode="users") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # get balance - response = yield result.get_app_stats(softId=867, mode="money") - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "chartData", "fromDate", "toDate"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - @asyncio.coroutine - def test_true_aiobalance(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # get balance - response = yield result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "balance"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - @asyncio.coroutine - def test_true_aiocontrol(self): - # prepare client - result = AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) - # complaint on result - response = yield result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="image" - ) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 - # complaint on result - response = yield result.complaint_on_result( - reported_id=self.WRONG_TASK_ID, captcha_type="recaptcha" - ) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 - - @asyncio.coroutine - def test_fail_aiocontrol_context(self): - # prepare client - with AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_fail - ) as result: - # get balance - response = yield result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - - # complaint on result - response = yield result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 1 - - @asyncio.coroutine - def test_true_aiocontrol_context(self): - # prepare client - with AntiCaptchaControl.aioAntiCaptchaControl( - anticaptcha_key=self.anticaptcha_key_true - ) as result: - # get balance - response = yield result.get_balance() - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "balance"] == list(response.keys()) - # check error code - assert response["errorId"] == 0 - - # complaint on result - response = yield result.complaint_on_result(reported_id=self.WRONG_TASK_ID) - # check response type - assert type(response) is dict - # check all dict keys - assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) - # check error code - assert response["errorId"] == 16 + \ No newline at end of file