From 95648626142ef05f6ea9fda73d2ed4381231f903 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sat, 18 Jan 2025 03:44:20 +0300 Subject: [PATCH] Update test_image_to_text.py --- tests/test_image_to_text.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_image_to_text.py b/tests/test_image_to_text.py index a9ba005a..2f0678aa 100644 --- a/tests/test_image_to_text.py +++ b/tests/test_image_to_text.py @@ -1,13 +1,8 @@ -import base64 - from tests.conftest import BaseTest from python3_capsolver.core.enum import ResponseStatusEnm from python3_capsolver.image_to_text import ImageToText from python3_capsolver.core.serializer import CaptchaResponseSer -with open("tests/files/captcha_example.jpeg", "rb") as img_file: - img_data = img_file.read() - class TestImageToTextBase(BaseTest): def test_captcha_handler_exist(self): @@ -16,13 +11,12 @@ def test_captcha_handler_exist(self): class TestImageToText(BaseTest): - image_body = base64.b64encode(img_data).decode("utf-8") """ Success tests """ def test_solve_image(self): - resp = ImageToText(api_key=self.API_KEY).captcha_handler(task_payload=dict(body=self.image_body)) + resp = ImageToText(api_key=self.API_KEY).captcha_handler(task_payload=dict(body=self.read_image_as_str())) assert isinstance(resp, dict) assert CaptchaResponseSer(**resp) assert resp["status"] == ResponseStatusEnm.Ready.value @@ -32,7 +26,9 @@ def test_solve_image(self): assert isinstance(resp["solution"], dict) async def test_aio_solve_image(self): - resp = await ImageToText(api_key=self.API_KEY).aio_captcha_handler(task_payload=dict(body=self.image_body)) + resp = await ImageToText(api_key=self.API_KEY).aio_captcha_handler( + task_payload=dict(body=self.read_image_as_str()) + ) assert isinstance(resp, dict) assert CaptchaResponseSer(**resp) assert resp["status"] == ResponseStatusEnm.Ready.value @@ -47,7 +43,7 @@ async def test_aio_solve_image(self): def test_captcha_handler_api_key_err(self): result = ImageToText(api_key=self.get_random_string(36)).captcha_handler( - task_payload=dict(body=self.image_body) + task_payload=dict(body=self.read_image_as_str()) ) assert result["errorId"] == 1 assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS" @@ -55,7 +51,7 @@ def test_captcha_handler_api_key_err(self): async def test_aio_captcha_handler_api_key_err(self): result = await ImageToText(api_key=self.get_random_string(36)).aio_captcha_handler( - task_payload=dict(body=self.image_body) + task_payload=dict(body=self.read_image_as_str()) ) assert result["errorId"] == 1 assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS"