diff --git a/.github/actions/build-project/action.yml b/.github/actions/build-project/action.yml index fe8b7a0..76e0be3 100644 --- a/.github/actions/build-project/action.yml +++ b/.github/actions/build-project/action.yml @@ -14,6 +14,17 @@ runs: with: python-version: ${{ inputs.python-version }} + - name: Install lxml system deps (Linux only) + shell: bash + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y \ + libxml2-dev \ + libxslt1-dev \ + python3-dev \ + build-essential + - name: Install host python dependencies shell: bash run: | diff --git a/.github/workflows/cd-master.yml b/.github/workflows/cd-master.yml index 9040e65..a4eb015 100644 --- a/.github/workflows/cd-master.yml +++ b/.github/workflows/cd-master.yml @@ -24,7 +24,7 @@ jobs: - name: Build the project uses: ./.github/actions/build-project with: - python-version: '3.x' + python-version: '3.9' gh-pages: needs: build @@ -35,7 +35,7 @@ jobs: uses: actions/download-artifact@v4 with: path: ./build - pattern: build.*.Linux-py3.x + pattern: build.*.Linux-py3.9 merge-multiple: true - name: Deploy to Github Pages diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 66d075f..b602289 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.x', '3.9'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] os: [ubuntu-latest, windows-latest] name: Build ${{ matrix.os }}-py${{ matrix.python-version }} diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index a2b3f18..be99fcb 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -36,7 +36,7 @@ jobs: - name: Set up python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: '3.9' - name: Lint sources shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e23d0..504fad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.0.2] - 2025-12-22 + +### Fixed + - API credentials checking from [Issue #42](https://github.com/b3yc0d3/rule34Py/issues/42) + ## [4.0.1] - 2025-08-31 ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4d19ee2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,36 @@ +# Contributing + +Thanks for taking an interest in contributing to the rule34Py project! + +* This project's **canonical upstream** is at https://github.com/b3yc0d3/rule34Py. +* File **bugs**, **enhancement requests**, and other **issues** to the GH issue tracker at https://github.com/b3yc0d3/rule34Py/issues. +* See the [Developer Guide](https://b3yc0d3.github.io/rule34Py/dev/developer-guide.html) for information about how to **build** this project from source and run tests. + + +## Submitting Changes + +#. Base your development branch off of the [upstream](https://github.com/b3yc0d3/rule34Py/tree/develop) ``develop`` reference. + +#. Before committing your changes, run the **project linter** using ``make``. It will use the ``ruff`` to lint all the project sources. + + .. code-block:: bash + + poetry install # Optional, if you have not done it previously. + make lint + + Fix or respond to any findings in the linter. + +#. Run the project's test suite against your changes. Ensure that all tests pass. + + .. code-block:: bash + + poetry install # Optional, if you have not done it previously. + make check + +#. Write a good commit message. If you are unsure of how, [this cbeams article](https://cbea.ms/git-commit/) gives reasonable suggestions. Commit your changes. + +#. Fork the canonical upstream repository on github. \[[GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)\] + +#. Push your development branch to your own fork. [Open a new Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against the upstream `develop` ref. + +#. Submit your PR. Respond to any PR build failures or feedback from the maintainers. diff --git a/pyproject.toml b/pyproject.toml index 35d3117..3c1fc99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ maintainers = [ ] readme = "README.md" requires-python = ">=3.9, <4.0" -version = "4.0.1" +version = "4.0.2" [project.urls] diff --git a/rule34Py/__init__.py b/rule34Py/__init__.py index 6831322..bb38143 100644 --- a/rule34Py/__init__.py +++ b/rule34Py/__init__.py @@ -1,6 +1,6 @@ # rule34Py - Python api wrapper for rule34.xxx # -# Copyright (C) 2022-2024 b3yc0d3 +# Copyright (C) 2022-2025 b3yc0d3 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/rule34Py/rule34.py b/rule34Py/rule34.py index 14ae0cb..f3d797b 100644 --- a/rule34Py/rule34.py +++ b/rule34Py/rule34.py @@ -138,7 +138,7 @@ def _get(self, *args, **kwargs) -> requests.Response: is_api_request = args[0].startswith(__api_url__) == True # check if api credentials are set - if is_api_request and self.user_id == None and self.api_key == None: + if is_api_request and self.user_id == None or self.api_key == None or (self.user_id == None and self.api_key == None): raise ValueError( "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information." ) diff --git a/tests/unit/test_rule34Py.py b/tests/unit/test_rule34Py.py index 22fb3eb..fdaa68c 100644 --- a/tests/unit/test_rule34Py.py +++ b/tests/unit/test_rule34Py.py @@ -250,3 +250,25 @@ def test_rule34Py_top_tags(rule34): assert isinstance(top_tags, list) assert len(top_tags) == 100 assert isinstance(top_tags[0], TopTag) + +def test_rule34Py_api_key(rule34): + rule34.api_key = None + with pytest.raises(ValueError) as execinfo: + rule34.top_tags() + + assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information." + +def test_rule34Py_user_id(rule34): + rule34.user_id = None + with pytest.raises(ValueError) as execinfo: + rule34.top_tags() + + assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information." + +def test_rule34Py_credentials(rule34): + rule34.api_key = None + rule34.user_id = None + with pytest.raises(ValueError) as execinfo: + rule34.top_tags() + + assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information." \ No newline at end of file