-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a28a5e9
commit 07e3a52
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
|
||
from tests.conftest import BaseTest | ||
from python3_capsolver.cloudflare import Cloudflare | ||
from python3_capsolver.core.enum import CaptchaTypeEnm | ||
|
||
|
||
class TestCloudflare(BaseTest): | ||
captcha_types = ( | ||
CaptchaTypeEnm.AntiCloudflareTask, | ||
CaptchaTypeEnm.AntiTurnstileTaskProxyLess, | ||
) | ||
|
||
@pytest.mark.parametrize("captcha_type", captcha_types) | ||
def test_captcha_handler_exist(self, captcha_type): | ||
instance = Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type) | ||
assert "captcha_handler" in instance.__dir__() | ||
assert "aio_captcha_handler" in instance.__dir__() | ||
|
||
@pytest.mark.parametrize("captcha_type", captcha_types) | ||
def test_api_key_err(self, captcha_type): | ||
result = Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler( | ||
task_payload={"some": "data"} | ||
) | ||
assert result["errorId"] == 1 | ||
assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA") | ||
assert result["solution"] is None | ||
|
||
@pytest.mark.parametrize("captcha_type", captcha_types) | ||
async def test_aio_api_key_err(self, captcha_type): | ||
result = await Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type).aio_captcha_handler( | ||
task_payload={"some": "data"} | ||
) | ||
assert result["errorId"] == 1 | ||
assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA") | ||
assert result["solution"] is None |