Skip to content

Commit 7d77a90

Browse files
author
Andrei
committed
Update test_mt_captcha.py
1 parent 8cea692 commit 7d77a90

1 file changed

Lines changed: 26 additions & 17 deletions

File tree

tests/test_mt_captcha.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
from tests.conftest import BaseTest
4-
from python3_capsolver.core.enum import ResponseStatusEnm
4+
from python3_capsolver.core.enum import MtCaptchaTypeEnm, ResponseStatusEnm
55
from python3_capsolver.mt_captcha import MtCaptcha
66
from python3_capsolver.core.serializer import CaptchaResponseSer
77

@@ -11,56 +11,65 @@
1111

1212

1313
class TestMtCaptchaBase(BaseTest):
14+
captcha_types = (MtCaptchaTypeEnm.MtCaptchaTask, MtCaptchaTypeEnm.MtCaptchaTaskProxyLess)
15+
1416
def test_captcha_handler_exist(self):
1517
assert "captcha_handler" in MtCaptcha.__dict__.keys()
1618

1719
def test_aio_captcha_handler_exist(self):
1820
assert "aio_captcha_handler" in MtCaptcha.__dict__.keys()
1921

20-
def test_no_website_url(self):
21-
with pytest.raises(TypeError):
22-
MtCaptcha(api_key=self.API_KEY, websiteKey=websiteKey, proxy=proxy)
23-
24-
def test_no_website_key(self):
22+
@pytest.mark.parametrize("captcha_type", captcha_types)
23+
def test_no_website_url(self, captcha_type: str):
2524
with pytest.raises(TypeError):
26-
MtCaptcha(api_key=self.API_KEY, websiteURL=websiteURL, proxy=proxy)
25+
MtCaptcha(api_key=self.API_KEY, captcha_type=captcha_type, websiteKey=websiteKey, proxy=proxy)
2726

28-
def test_no_proxy(self):
27+
@pytest.mark.parametrize("captcha_type", captcha_types)
28+
def test_no_website_key(self, captcha_type: str):
2929
with pytest.raises(TypeError):
30-
MtCaptcha(api_key=self.API_KEY, websiteURL=websiteURL, websiteKey=websiteKey)
30+
MtCaptcha(api_key=self.API_KEY, captcha_type=captcha_type, websiteURL=websiteURL, proxy=proxy)
3131

3232

3333
class TestMtCaptcha(BaseTest):
34+
captcha_types = (MtCaptchaTypeEnm.MtCaptchaTask, MtCaptchaTypeEnm.MtCaptchaTaskProxyLess)
3435
"""
3536
Success tests
3637
"""
3738

3839
@pytest.mark.parametrize("proxy_type", BaseTest.proxyTypes)
39-
def test_params(self, proxy_type: str):
40-
MtCaptcha(api_key=self.API_KEY, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy)
40+
@pytest.mark.parametrize("captcha_type", captcha_types)
41+
def test_params(self, proxy_type: str, captcha_type: str):
42+
MtCaptcha(
43+
api_key=self.API_KEY, captcha_type=captcha_type, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
44+
)
4145

4246
@pytest.mark.parametrize("proxy_type", BaseTest.proxyTypes)
43-
def test_params_context(self, proxy_type: str):
44-
with MtCaptcha(api_key=self.API_KEY, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy) as instance:
47+
@pytest.mark.parametrize("captcha_type", captcha_types)
48+
def test_params_context(self, proxy_type: str, captcha_type: str):
49+
with MtCaptcha(
50+
api_key=self.API_KEY, captcha_type=captcha_type, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
51+
) as instance:
4552
pass
4653

4754
"""
4855
Failed tests
4956
"""
5057

51-
def test_proxy_err(self):
58+
@pytest.mark.parametrize("captcha_type", captcha_types)
59+
def test_proxy_err(self, captcha_type: str):
5260
resp = MtCaptcha(
53-
api_key=self.API_KEY, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
61+
api_key=self.API_KEY, captcha_type=captcha_type, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
5462
).captcha_handler()
5563
assert isinstance(resp, CaptchaResponseSer)
5664
assert resp.status == ResponseStatusEnm.Processing
5765
assert resp.errorId == 1
5866
assert resp.errorCode == "ERROR_INVALID_TASK_DATA"
5967
assert resp.solution is None
6068

61-
async def test_aio_proxy_err(self):
69+
@pytest.mark.parametrize("captcha_type", captcha_types)
70+
async def test_aio_proxy_err(self, captcha_type: str):
6271
resp = await MtCaptcha(
63-
api_key=self.API_KEY, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
72+
api_key=self.API_KEY, captcha_type=captcha_type, websiteURL=websiteURL, websiteKey=websiteKey, proxy=proxy
6473
).aio_captcha_handler()
6574
assert isinstance(resp, CaptchaResponseSer)
6675
assert resp.status == ResponseStatusEnm.Processing

0 commit comments

Comments
 (0)