diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e69ae7e..51e2b2f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,7 +2,7 @@ name: CI on: [push] jobs: tests: - runs-on: ubuntu-20.04 + runs-on: ubuntu-25.04 steps: - uses: actions/checkout@master with: diff --git a/requirements.txt b/requirements.txt index 4b4ba7f..ebab577 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,202 +1,223 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: # # pip-compile --output-file=requirements.txt requirements.in # -attrs==21.4.0 - # via pytest -black==22.3.0 +attrs==25.3.0 + # via wmctrl +babel==2.17.0 + # via mkdocs-material +backrefs==5.8 + # via mkdocs-material +black==25.1.0 # via flake8-black -bleach==5.0.0 - # via readme-renderer -build==0.7.0 - # via -r requirements.in -certifi==2021.10.8 +build==1.2.2.post1 + # via + # -r requirements.in + # pip-tools +certifi==2025.1.31 # via requests -charset-normalizer==2.0.12 +cffi==1.17.1 + # via cryptography +charset-normalizer==3.4.1 # via requests -click==8.1.2 +click==8.1.8 # via # black # mkdocs # pip-tools -commonmark==0.9.1 - # via rich -coverage[toml]==6.3.2 +colorama==0.4.6 + # via mkdocs-material +coverage[toml]==7.8.0 # via pytest-cov -docutils==0.18.1 +cryptography==44.0.2 + # via secretstorage +docutils==0.21.2 # via readme-renderer fancycompleter==0.9.1 # via pdbpp -flake8==4.0.1 +flake8==7.2.0 # via # -r requirements.in # flake8-black # flake8-isort -flake8-black==0.3.2 +flake8-black==0.3.6 # via -r requirements.in -flake8-isort==4.1.1 +flake8-isort==6.1.2 # via -r requirements.in -ghp-import==2.0.2 +ghp-import==2.1.0 # via mkdocs -idna==3.3 +id==1.5.0 + # via twine +idna==3.10 # via requests -importlib-metadata==4.11.3 - # via - # keyring - # markdown - # mkdocs - # twine -iniconfig==1.1.1 +iniconfig==2.1.0 # via pytest -isort==5.10.1 +isort==6.0.1 # via flake8-isort -jinja2==3.1.1 +jaraco-classes==3.4.0 + # via keyring +jaraco-context==6.0.1 + # via keyring +jaraco-functools==4.1.0 + # via keyring +jeepney==0.9.0 + # via + # keyring + # secretstorage +jinja2==3.1.6 # via # mkdocs # mkdocs-material -keyring==23.5.0 +keyring==25.6.0 # via twine -markdown==3.3.6 +markdown==3.7 # via # mkdocs # mkdocs-material # pymdown-extensions -markupsafe==2.1.1 - # via jinja2 -mccabe==0.6.1 +markdown-it-py==3.0.0 + # via rich +markupsafe==3.0.2 + # via + # jinja2 + # mkdocs +mccabe==0.7.0 # via flake8 +mdurl==0.1.2 + # via markdown-it-py mergedeep==1.3.4 - # via mkdocs -mkdocs==1.3.0 + # via + # mkdocs + # mkdocs-get-deps +mkdocs==1.6.1 # via # -r requirements.in # mkdocs-material -mkdocs-material==8.2.11 +mkdocs-get-deps==0.2.0 + # via mkdocs +mkdocs-material==9.6.11 # via -r requirements.in -mkdocs-material-extensions==1.0.3 +mkdocs-material-extensions==1.3.1 # via mkdocs-material -mypy==0.942 +more-itertools==10.6.0 + # via + # jaraco-classes + # jaraco-functools +mypy==1.15.0 # via -r requirements.in -mypy-extensions==0.4.3 +mypy-extensions==1.0.0 # via # black # mypy -packaging==21.3 +nh3==0.2.21 + # via readme-renderer +packaging==24.2 # via + # black # build # mkdocs # pytest # pytest-sugar -pathspec==0.9.0 - # via black + # twine +paginate==0.5.7 + # via mkdocs-material +pathspec==0.12.1 + # via + # black + # mkdocs pdbpp==0.10.3 # via -r requirements.in -pep517==0.12.0 - # via - # build - # pip-tools -pip-tools==6.6.0 +pip-tools==7.4.1 # via -r requirements.in -pkginfo==1.8.2 - # via twine -platformdirs==2.5.2 - # via black -pluggy==1.0.0 - # via pytest -py==1.11.0 +platformdirs==4.3.7 + # via + # black + # mkdocs-get-deps +pluggy==1.5.0 # via pytest -pycodestyle==2.8.0 +pycodestyle==2.13.0 # via flake8 -pyflakes==2.4.0 +pycparser==2.22 + # via cffi +pyflakes==3.3.2 # via flake8 -pygments==2.11.2 +pygments==2.19.1 # via # -r requirements.in # mkdocs-material # pdbpp # readme-renderer # rich -pymdown-extensions==9.3 +pymdown-extensions==10.14.3 # via mkdocs-material -pyparsing==3.0.8 - # via packaging +pyproject-hooks==1.2.0 + # via + # build + # pip-tools pyrepl==0.9.0 # via fancycompleter -pytest==7.1.2 +pytest==8.3.5 # via # -r requirements.in # pytest-cov # pytest-mock # pytest-sugar -pytest-cov==3.0.0 +pytest-cov==6.1.0 # via pytest-cover pytest-cover==3.0.0 # via pytest-coverage pytest-coverage==0.0 # via -r requirements.in -pytest-mock==3.7.0 +pytest-mock==3.14.0 # via -r requirements.in -pytest-sugar==0.9.4 +pytest-sugar==1.0.0 # via -r requirements.in -python-dateutil==2.8.2 +python-dateutil==2.9.0.post0 # via ghp-import -pyyaml==6.0 +pyyaml==6.0.2 # via # mkdocs + # mkdocs-get-deps + # pymdown-extensions # pyyaml-env-tag pyyaml-env-tag==0.1 # via mkdocs -readme-renderer==35.0 +readme-renderer==44.0 # via twine -requests==2.27.1 +requests==2.32.3 # via + # id + # mkdocs-material # requests-toolbelt # twine -requests-toolbelt==0.9.1 +requests-toolbelt==1.0.0 # via twine rfc3986==2.0.0 # via twine -rich==12.3.0 +rich==14.0.0 # via twine -six==1.16.0 - # via - # bleach - # python-dateutil -termcolor==1.1.0 +secretstorage==3.3.3 + # via keyring +six==1.17.0 + # via python-dateutil +termcolor==3.0.0 # via pytest-sugar -testfixtures==6.18.5 - # via flake8-isort -tomli==2.0.1 - # via - # black - # build - # flake8-black - # mypy - # pep517 - # pytest -twine==4.0.0 +twine==6.1.0 # via -r requirements.in -typing-extensions==4.2.0 - # via - # black - # mypy - # rich -urllib3==1.26.9 +typing-extensions==4.13.0 + # via mypy +urllib3==2.3.0 # via # requests # twine -watchdog==2.1.7 +watchdog==6.0.0 # via mkdocs -webencodings==0.5.1 - # via bleach -wheel==0.37.1 +wheel==0.45.1 # via pip-tools -wmctrl==0.4 +wmctrl==0.5 # via pdbpp -zipp==3.8.0 - # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/setup.cfg b/setup.cfg index 27ae991..eeca7a2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = rules-engine -version = 0.3.0 +version = 0.3.1 author = Fyndiq AB author_email = support@fyndiq.com description = Rules engine diff --git a/src/rules_engine/__init__.py b/src/rules_engine/__init__.py index 790f7c0..e23d5ec 100644 --- a/src/rules_engine/__init__.py +++ b/src/rules_engine/__init__.py @@ -13,6 +13,8 @@ class Result: value: Any message: Optional[str] + def __bool__(self): + return bool(self.value) class Rule: def __init__( diff --git a/tests/test_result.py b/tests/test_result.py new file mode 100644 index 0000000..a929dcf --- /dev/null +++ b/tests/test_result.py @@ -0,0 +1,19 @@ +import pytest + +from src.rules_engine import Result + + +@pytest.mark.parametrize( + "value, message, expected_result", + [ + (True, "Success", True), + ("aaa", "Success", True), + (2, "Success", True), + (False, None, False), + (None, None, False), + (False, "Failure", False), + ], +) +def test_result(value, message, expected_result): + result = Result(value, message) + assert bool(result) is expected_result