diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f237e73..e6b2396c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,7 @@ jobs: env: RUCAPTCHA_KEY: ${{ secrets.RUCAPTCHA_KEY }} DEATHBYCAPTCHA_KEY: ${{ secrets.DEATHBYCAPTCHA_KEY }} + CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_COVERAGE_ID }} strategy: fail-fast: false matrix: @@ -50,6 +51,11 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: /home/runner/work/python-rucaptcha/python-rucaptcha/coverage/coverage.xml + files: ${{github.workspace}}/coverage/coverage.xml fail_ci_if_error: true verbose: true + + - name: Upload coverage to Code Climate + uses: paambaati/codeclimate-action@v5.0.0 + with: + coverageLocations: ${{github.workspace}}/coverage/coverage.xml:coverage.py diff --git a/docs/conf.py b/docs/conf.py index 44bddb31..33348f1c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,6 +38,7 @@ "sphinx.ext.napoleon", "pallets_sphinx_themes", "sphinxcontrib.autodoc_pydantic", + "enum_tools.autoenum", ) myst_enable_extensions = ["deflist"] intersphinx_mapping = {"python": ("https://docs.python.org/3.10/", None)} diff --git a/docs/modules/enum/info.rst b/docs/modules/enum/info.rst index 52b3cbb2..18eebd3c 100644 --- a/docs/modules/enum/info.rst +++ b/docs/modules/enum/info.rst @@ -8,94 +8,71 @@ To import this module: from python_rucaptcha.core import enums -.. autoclass:: python_rucaptcha.core.enums.MyEnum +.. autoenum:: python_rucaptcha.core.enums.MyEnum :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.ServiceEnm +.. autoenum:: python_rucaptcha.core.enums.ServiceEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.SaveFormatsEnm +.. autoenum:: python_rucaptcha.core.enums.SaveFormatsEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.GeetestEnm +.. autoenum:: python_rucaptcha.core.enums.GeetestEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.ImageCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.ImageCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.CapyPuzzleEnm +.. autoenum:: python_rucaptcha.core.enums.CapyPuzzleEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.FunCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.FunCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.ReCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.ReCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.LeminCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.LeminCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.HCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.HCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.KeyCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.KeyCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.RotateCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.RotateCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.ControlEnm +.. autoenum:: python_rucaptcha.core.enums.ControlEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.TurnstileCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.TurnstileCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.AmazonWAFCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.AmazonWAFCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.CutCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.CutCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.DataDomeSliderEnm +.. autoenum:: python_rucaptcha.core.enums.DataDomeSliderEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.CyberSiARAEnm +.. autoenum:: python_rucaptcha.core.enums.CyberSiARAEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.MTCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.MTCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.BoundingBoxCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.BoundingBoxCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.DrawAroundCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.DrawAroundCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.CoordinatesCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.CoordinatesCaptchaEnm :members: - :undoc-members: -.. autoclass:: python_rucaptcha.core.enums.GridCaptchaEnm +.. autoenum:: python_rucaptcha.core.enums.GridCaptchaEnm :members: - :undoc-members: \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt index c293b896..c1ff2541 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,3 +4,4 @@ myst-parser==2.0.0 autodoc_pydantic==2.0.1 pydantic==2.5.2 pydantic-settings==2.1.0 +enum-tools[sphinx]==0.11.0 diff --git a/src/python_rucaptcha/core/serializer.py b/src/python_rucaptcha/core/serializer.py index b25b0d85..b74df0eb 100644 --- a/src/python_rucaptcha/core/serializer.py +++ b/src/python_rucaptcha/core/serializer.py @@ -20,11 +20,6 @@ class TaskSer(MyBaseModel): type: str -class ErrorFieldsSer(Struct): - errorCode: str = None - errorDescription: str = None - - class CreateTaskBaseSer(MyBaseModel): clientKey: str task: TaskSer = {} @@ -62,8 +57,7 @@ def urls_set(self): """ -class GetTaskResultResponseSer(MyBaseModel, ErrorFieldsSer): - errorId: int = 0 +class GetTaskResultResponseSer(MyBaseModel): status: str = "ready" solution: dict = None cost: float = None @@ -74,3 +68,7 @@ class GetTaskResultResponseSer(MyBaseModel, ErrorFieldsSer): taskId: int = None # control method params balance: float = None + # error info + errorId: int = 0 + errorCode: str = None + errorDescription: str = None diff --git a/src/python_rucaptcha/gee_test.py b/src/python_rucaptcha/gee_test.py index ce6f42da..75200403 100644 --- a/src/python_rucaptcha/gee_test.py +++ b/src/python_rucaptcha/gee_test.py @@ -194,11 +194,7 @@ def captcha_handler(self, challenge: str, **kwargs) -> dict: Notes: Check class docstirng for more info """ - if self.method == GeetestEnm.GeeTestTaskProxyless.value: - if challenge is not None: - self.create_task_payload["task"].update({"challenge": challenge}) - else: - raise ValueError(f"For {self.method} challenge is required") + self.create_task_payload["task"].update({"challenge": challenge}) return self._processing_response(**kwargs) @@ -215,10 +211,6 @@ async def aio_captcha_handler(self, challenge: str) -> dict: Notes: Check class docstirng for more info """ - if self.method == GeetestEnm.GeeTestTaskProxyless.value: - if challenge is not None: - self.create_task_payload["task"].update({"challenge": challenge}) - else: - raise ValueError(f"For {self.method} challenge is required") + self.create_task_payload["task"].update({"challenge": challenge}) return await self._aio_processing_response()