Skip to content

Commit c37a3d1

Browse files
author
Andrei
committed
upd tests
1 parent 3aef86d commit c37a3d1

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

tests/test_datadome_slider.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ def test_captcha_handler_exist(self):
1616
def test_aio_captcha_handler_exist(self):
1717
assert "aio_captcha_handler" in DatadomeSlider.__dict__.keys()
1818

19+
def test_wrong_captcha_type(self):
20+
with pytest.raises(ValueError):
21+
DatadomeSlider(
22+
api_key=self.API_KEY,
23+
captcha_type=self.get_random_string(36),
24+
websiteURL=websiteURL,
25+
captchaUrl=captchaUrl,
26+
userAgent=self.get_random_string(36),
27+
)
28+
1929

2030
class TestDatadomeSlider(BaseTest):
2131
"""

tests/test_image_to_text.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import base64
22

3+
import pytest
4+
35
from tests.conftest import BaseTest
46
from python3_capsolver.core.enum import ResponseStatusEnm
57
from python3_capsolver.image_to_text import ImageToText
@@ -9,18 +11,24 @@
911
img_data = img_file.read()
1012

1113

12-
class TestImageToText(BaseTest):
13-
image_body = base64.b64encode(img_data).decode("utf-8")
14-
"""
15-
Success tests
16-
"""
17-
14+
class TestImageToTextBase(BaseTest):
1815
def test_captcha_handler_exist(self):
1916
assert "captcha_handler" in ImageToText.__dict__.keys()
2017

2118
def test_aio_captcha_handler_exist(self):
2219
assert "aio_captcha_handler" in ImageToText.__dict__.keys()
2320

21+
def test_wrong_captcha_type(self):
22+
with pytest.raises(ValueError):
23+
ImageToText(api_key=self.API_KEY, captcha_type=self.get_random_string())
24+
25+
26+
class TestImageToText(BaseTest):
27+
image_body = base64.b64encode(img_data).decode("utf-8")
28+
"""
29+
Success tests
30+
"""
31+
2432
def test_solve_image(self):
2533
resp = ImageToText(api_key=self.API_KEY).captcha_handler(body=self.image_body)
2634
assert isinstance(resp, CaptchaResponseSer)

tests/test_mt_captcha.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def test_captcha_handler_exist(self):
1919
def test_aio_captcha_handler_exist(self):
2020
assert "aio_captcha_handler" in MtCaptcha.__dict__.keys()
2121

22+
def test_wrong_captcha_type(self):
23+
with pytest.raises(ValueError):
24+
MtCaptcha(
25+
api_key=self.API_KEY,
26+
captcha_type=self.get_random_string(),
27+
websiteKey=websiteKey,
28+
proxy=proxy,
29+
websiteURL=websiteURL,
30+
)
31+
2232
@pytest.mark.parametrize("captcha_type", captcha_types)
2333
def test_no_website_url(self, captcha_type: str):
2434
with pytest.raises(TypeError):

0 commit comments

Comments
 (0)