Skip to content

Commit

Permalink
Update test_image.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Oct 3, 2023
1 parent 3d6fdcb commit f605e35
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ def test_methods_exists(self):
assert "aio_captcha_handler" in ImageCaptcha.__dict__.keys()

@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
def test_basic_data_link(self, save_format):
def test_basic_link(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)
assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
result = instance.captcha_handler(captcha_link=self.captcha_url)

assert isinstance(result, dict) is True

if not result["errorId"]:
assert result["status"] == "ready"
assert isinstance(result["solution"]["text"], str) is True
assert isinstance(result["taskId"], int) is True
else:
assert result["errorId"] == 1
assert result["status"] == "ERROR_CAPTCHA_UNSOLVABLE"

@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
def test_basic_data_file(self, save_format):
def test_basic_file(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)
assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
result = instance.captcha_handler(captcha_file=self.captcha_file)
Expand All @@ -43,7 +53,7 @@ def test_basic_data_file(self, save_format):
assert result.keys() == GetTaskResultRequestSer().dict().keys()

@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
def test_basic_data_base64(self, save_format):
def test_basic_base64(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)

assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
Expand All @@ -64,7 +74,7 @@ def test_basic_data_base64(self, save_format):

@pytest.mark.asyncio
@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
async def test_aio_basic_data_link(self, save_format):
async def test_aio_basic_link(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)
assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
result = await instance.aio_captcha_handler(captcha_link=self.captcha_url)
Expand All @@ -81,7 +91,7 @@ async def test_aio_basic_data_link(self, save_format):

@pytest.mark.asyncio
@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
async def test_aio_basic_data_file(self, save_format):
async def test_aio_basic_file(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)
assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
result = await instance.aio_captcha_handler(captcha_file=self.captcha_file)
Expand All @@ -98,7 +108,7 @@ async def test_aio_basic_data_file(self, save_format):

@pytest.mark.asyncio
@pytest.mark.parametrize("save_format", [SaveFormatsEnm.TEMP, SaveFormatsEnm.CONST])
async def test_aio_basic_data_base64(self, save_format):
async def test_aio_basic_base64(self, save_format):
instance = ImageCaptcha(rucaptcha_key=self.RUCAPTCHA_KEY, save_format=save_format)

assert instance.params.rucaptcha_key == self.RUCAPTCHA_KEY
Expand Down

0 comments on commit f605e35

Please sign in to comment.