chore: remove black (#3437)

This commit is contained in:
Hayden 2024-04-11 20:36:55 -05:00 committed by GitHub
parent 94678fe6e0
commit 9e6ae2e514
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 189 additions and 133 deletions

View File

@ -30,7 +30,6 @@
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"matangover.mypy", "matangover.mypy",
"ms-python.black-formatter", "ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint", "ms-python.pylint",
"ms-python.python", "ms-python.python",
"ms-python.vscode-pylance", "ms-python.vscode-pylance",

View File

@ -66,7 +66,7 @@ jobs:
id: cache-validate id: cache-validate
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true' if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
run: | run: |
echo "import black;print('venv good?')" > test.py && poetry run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT echo "import fastapi;print('venv good?')" > test.py && poetry run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT
rm test.py rm test.py
continue-on-error: true continue-on-error: true
@ -78,9 +78,9 @@ jobs:
poetry add "psycopg2-binary==2.9.9" poetry add "psycopg2-binary==2.9.9"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' || steps.cache-validate.outputs.cache-hit-success != 'true' if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' || steps.cache-validate.outputs.cache-hit-success != 'true'
- name: Formatting (Black) - name: Formatting (Ruff)
run: | run: |
poetry run black . --check poetry run ruff format . --check
- name: Lint (Ruff) - name: Lint (Ruff)
run: | run: |

View File

@ -10,7 +10,8 @@ repos:
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
exclude: ^tests/data/ exclude: ^tests/data/
- repo: https://github.com/psf/black - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 24.1.0 # Ruff version.
rev: v0.3.5
hooks: hooks:
- id: black - id: ruff-format

View File

@ -60,8 +60,5 @@
}, },
"[vue]": { "[vue]": {
"editor.formatOnSave": false "editor.formatOnSave": false
}, }
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
},
} }

View File

@ -74,6 +74,7 @@ tasks:
desc: run code generators desc: run code generators
cmds: cmds:
- poetry run python dev/code-generation/main.py - poetry run python dev/code-generation/main.py
- task: py:format
dev:services: dev:services:
desc: starts postgres and mailpit containers desc: starts postgres and mailpit containers
@ -105,7 +106,7 @@ tasks:
py:format: py:format:
desc: runs python code formatter desc: runs python code formatter
cmds: cmds:
- poetry run black mealie - poetry run ruff format .
py:lint: py:lint:
desc: runs python linter desc: runs python linter
@ -146,6 +147,12 @@ tasks:
cmds: cmds:
- poetry run python mealie/app.py - poetry run python mealie/app.py
py:migrate:
desc: generates a new migration file e.g. task py:migrate:generate "add new column"
cmds:
- poetry run alembic revision --autogenerate -m "{{ .CLI_ARGS }}"
- task: py:format
ui:build: ui:build:
desc: builds the frontend in frontend/dist desc: builds the frontend in frontend/dist
dir: frontend dir: frontend

View File

@ -58,15 +58,3 @@ sqlalchemy.url =
# post_write_hooks defines scripts or Python functions that are run # post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further # on newly generated revision scripts. See the documentation for further
# detail and examples # detail and examples
hooks = isort, black
# format using "isort" - use the console_scripts runner, against the "isort" entrypoint
isort.type = console_scripts
isort.entrypoint = isort
isort.options = REVISION_SCRIPT_FILENAME
# format using "black" - use the console_scripts runner, against the "black" entrypoint
black.type = console_scripts
black.entrypoint = black
black.options = REVISION_SCRIPT_FILENAME

View File

@ -3,8 +3,6 @@ import re
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
import black
import isort
from jinja2 import Template from jinja2 import Template
from rich.logging import RichHandler from rich.logging import RichHandler
@ -23,10 +21,7 @@ def render_python_template(template_file: Path | str, dest: Path, data: dict):
text = tplt.render(data=data) text = tplt.render(data=data)
text = black.format_str(text, mode=black.FileMode())
dest.write_text(text) dest.write_text(text)
isort.file(dest)
@dataclass @dataclass

63
poetry.lock generated
View File

@ -209,52 +209,6 @@ charset-normalizer = ["charset-normalizer"]
html5lib = ["html5lib"] html5lib = ["html5lib"]
lxml = ["lxml"] lxml = ["lxml"]
[[package]]
name = "black"
version = "24.3.0"
description = "The uncompromising code formatter."
optional = false
python-versions = ">=3.8"
files = [
{file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"},
{file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"},
{file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"},
{file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"},
{file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"},
{file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"},
{file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"},
{file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"},
{file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"},
{file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"},
{file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"},
{file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"},
{file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"},
{file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"},
{file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"},
{file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"},
{file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"},
{file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"},
{file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"},
{file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"},
{file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"},
{file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"},
]
[package.dependencies]
click = ">=8.0.0"
mypy-extensions = ">=0.4.3"
packaging = ">=22.0"
pathspec = ">=0.9.0"
platformdirs = ">=2"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""}
[package.extras]
colorama = ["colorama (>=0.4.3)"]
d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"]
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
uvloop = ["uvloop (>=0.15.2)"]
[[package]] [[package]]
name = "certifi" name = "certifi"
version = "2022.12.7" version = "2022.12.7"
@ -731,7 +685,6 @@ files = [
{file = "greenlet-2.0.2-cp27-cp27m-win32.whl", hash = "sha256:6c3acb79b0bfd4fe733dff8bc62695283b57949ebcca05ae5c129eb606ff2d74"}, {file = "greenlet-2.0.2-cp27-cp27m-win32.whl", hash = "sha256:6c3acb79b0bfd4fe733dff8bc62695283b57949ebcca05ae5c129eb606ff2d74"},
{file = "greenlet-2.0.2-cp27-cp27m-win_amd64.whl", hash = "sha256:283737e0da3f08bd637b5ad058507e578dd462db259f7f6e4c5c365ba4ee9343"}, {file = "greenlet-2.0.2-cp27-cp27m-win_amd64.whl", hash = "sha256:283737e0da3f08bd637b5ad058507e578dd462db259f7f6e4c5c365ba4ee9343"},
{file = "greenlet-2.0.2-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:d27ec7509b9c18b6d73f2f5ede2622441de812e7b1a80bbd446cb0633bd3d5ae"}, {file = "greenlet-2.0.2-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:d27ec7509b9c18b6d73f2f5ede2622441de812e7b1a80bbd446cb0633bd3d5ae"},
{file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d967650d3f56af314b72df7089d96cda1083a7fc2da05b375d2bc48c82ab3f3c"},
{file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:30bcf80dda7f15ac77ba5af2b961bdd9dbc77fd4ac6105cee85b0d0a5fcf74df"}, {file = "greenlet-2.0.2-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:30bcf80dda7f15ac77ba5af2b961bdd9dbc77fd4ac6105cee85b0d0a5fcf74df"},
{file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26fbfce90728d82bc9e6c38ea4d038cba20b7faf8a0ca53a9c07b67318d46088"}, {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26fbfce90728d82bc9e6c38ea4d038cba20b7faf8a0ca53a9c07b67318d46088"},
{file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9190f09060ea4debddd24665d6804b995a9c122ef5917ab26e1566dcc712ceeb"}, {file = "greenlet-2.0.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9190f09060ea4debddd24665d6804b995a9c122ef5917ab26e1566dcc712ceeb"},
@ -740,7 +693,6 @@ files = [
{file = "greenlet-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:76ae285c8104046b3a7f06b42f29c7b73f77683df18c49ab5af7983994c2dd91"}, {file = "greenlet-2.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:76ae285c8104046b3a7f06b42f29c7b73f77683df18c49ab5af7983994c2dd91"},
{file = "greenlet-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:2d4686f195e32d36b4d7cf2d166857dbd0ee9f3d20ae349b6bf8afc8485b3645"}, {file = "greenlet-2.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:2d4686f195e32d36b4d7cf2d166857dbd0ee9f3d20ae349b6bf8afc8485b3645"},
{file = "greenlet-2.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c4302695ad8027363e96311df24ee28978162cdcdd2006476c43970b384a244c"}, {file = "greenlet-2.0.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c4302695ad8027363e96311df24ee28978162cdcdd2006476c43970b384a244c"},
{file = "greenlet-2.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d4606a527e30548153be1a9f155f4e283d109ffba663a15856089fb55f933e47"},
{file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c48f54ef8e05f04d6eff74b8233f6063cb1ed960243eacc474ee73a2ea8573ca"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c48f54ef8e05f04d6eff74b8233f6063cb1ed960243eacc474ee73a2ea8573ca"},
{file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a1846f1b999e78e13837c93c778dcfc3365902cfb8d1bdb7dd73ead37059f0d0"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a1846f1b999e78e13837c93c778dcfc3365902cfb8d1bdb7dd73ead37059f0d0"},
{file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a06ad5312349fec0ab944664b01d26f8d1f05009566339ac6f63f56589bc1a2"}, {file = "greenlet-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a06ad5312349fec0ab944664b01d26f8d1f05009566339ac6f63f56589bc1a2"},
@ -770,7 +722,6 @@ files = [
{file = "greenlet-2.0.2-cp37-cp37m-win32.whl", hash = "sha256:3f6ea9bd35eb450837a3d80e77b517ea5bc56b4647f5502cd28de13675ee12f7"}, {file = "greenlet-2.0.2-cp37-cp37m-win32.whl", hash = "sha256:3f6ea9bd35eb450837a3d80e77b517ea5bc56b4647f5502cd28de13675ee12f7"},
{file = "greenlet-2.0.2-cp37-cp37m-win_amd64.whl", hash = "sha256:7492e2b7bd7c9b9916388d9df23fa49d9b88ac0640db0a5b4ecc2b653bf451e3"}, {file = "greenlet-2.0.2-cp37-cp37m-win_amd64.whl", hash = "sha256:7492e2b7bd7c9b9916388d9df23fa49d9b88ac0640db0a5b4ecc2b653bf451e3"},
{file = "greenlet-2.0.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:b864ba53912b6c3ab6bcb2beb19f19edd01a6bfcbdfe1f37ddd1778abfe75a30"}, {file = "greenlet-2.0.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:b864ba53912b6c3ab6bcb2beb19f19edd01a6bfcbdfe1f37ddd1778abfe75a30"},
{file = "greenlet-2.0.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1087300cf9700bbf455b1b97e24db18f2f77b55302a68272c56209d5587c12d1"},
{file = "greenlet-2.0.2-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:ba2956617f1c42598a308a84c6cf021a90ff3862eddafd20c3333d50f0edb45b"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:ba2956617f1c42598a308a84c6cf021a90ff3862eddafd20c3333d50f0edb45b"},
{file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3a569657468b6f3fb60587e48356fe512c1754ca05a564f11366ac9e306526"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3a569657468b6f3fb60587e48356fe512c1754ca05a564f11366ac9e306526"},
{file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8eab883b3b2a38cc1e050819ef06a7e6344d4a990d24d45bc6f2cf959045a45b"}, {file = "greenlet-2.0.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8eab883b3b2a38cc1e050819ef06a7e6344d4a990d24d45bc6f2cf959045a45b"},
@ -779,7 +730,6 @@ files = [
{file = "greenlet-2.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0ef99cdbe2b682b9ccbb964743a6aca37905fda5e0452e5ee239b1654d37f2a"}, {file = "greenlet-2.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0ef99cdbe2b682b9ccbb964743a6aca37905fda5e0452e5ee239b1654d37f2a"},
{file = "greenlet-2.0.2-cp38-cp38-win32.whl", hash = "sha256:b80f600eddddce72320dbbc8e3784d16bd3fb7b517e82476d8da921f27d4b249"}, {file = "greenlet-2.0.2-cp38-cp38-win32.whl", hash = "sha256:b80f600eddddce72320dbbc8e3784d16bd3fb7b517e82476d8da921f27d4b249"},
{file = "greenlet-2.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:4d2e11331fc0c02b6e84b0d28ece3a36e0548ee1a1ce9ddde03752d9b79bba40"}, {file = "greenlet-2.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:4d2e11331fc0c02b6e84b0d28ece3a36e0548ee1a1ce9ddde03752d9b79bba40"},
{file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8512a0c38cfd4e66a858ddd1b17705587900dd760c6003998e9472b77b56d417"},
{file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:88d9ab96491d38a5ab7c56dd7a3cc37d83336ecc564e4e8816dbed12e5aaefc8"}, {file = "greenlet-2.0.2-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:88d9ab96491d38a5ab7c56dd7a3cc37d83336ecc564e4e8816dbed12e5aaefc8"},
{file = "greenlet-2.0.2-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:561091a7be172ab497a3527602d467e2b3fbe75f9e783d8b8ce403fa414f71a6"}, {file = "greenlet-2.0.2-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:561091a7be172ab497a3527602d467e2b3fbe75f9e783d8b8ce403fa414f71a6"},
{file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:971ce5e14dc5e73715755d0ca2975ac88cfdaefcaab078a284fea6cfabf866df"}, {file = "greenlet-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:971ce5e14dc5e73715755d0ca2975ac88cfdaefcaab078a284fea6cfabf866df"},
@ -2298,7 +2248,6 @@ files = [
{file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"},
{file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"},
{file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"},
{file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"},
{file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"},
{file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"},
{file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"},
@ -2306,16 +2255,8 @@ files = [
{file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"},
{file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"},
{file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"},
{file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"},
{file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"},
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
{file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"},
{file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"},
{file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"},
{file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"},
@ -2332,7 +2273,6 @@ files = [
{file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"},
{file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"},
{file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"},
{file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"},
{file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"},
{file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"},
{file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"},
@ -2340,7 +2280,6 @@ files = [
{file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"},
{file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"},
{file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"},
{file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"},
{file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"},
{file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"},
{file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"},
@ -3245,4 +3184,4 @@ pgsql = ["psycopg2-binary"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.10" python-versions = "^3.10"
content-hash = "80de6c770dadd95c0b419c301a6e5e46b32d5d76389b8340a52b2a1b1d10d173" content-hash = "7c5f6bf8660394ee97b85b575f3cefd705bbd3939db2b20ccc988047822dbc5d"

View File

@ -53,7 +53,6 @@ pillow-heif = "^0.16.0"
psycopg2-binary = { version = "^2.9.1" } psycopg2-binary = { version = "^2.9.1" }
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
black = "^24.0.0"
coverage = "^7.0" coverage = "^7.0"
coveragepy-lcov = "^0.1.1" coveragepy-lcov = "^0.1.1"
mkdocs-material = "^9.0.0" mkdocs-material = "^9.0.0"
@ -76,13 +75,6 @@ types-urllib3 = "^1.26.11"
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
[tool.black]
line-length = 120
target-version = ["py310"]
[tool.isort]
line_length = 120
[tool.vulture] [tool.vulture]
exclude = ["**/models/**/*.py", "dir/"] exclude = ["**/models/**/*.py", "dir/"]
ignore_decorators = ["@*router.*", "@app.on_event", "@field_validator", "@controller"] ignore_decorators = ["@*router.*", "@app.on_event", "@field_validator", "@controller"]

View File

@ -22,9 +22,17 @@ from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSave
from mealie.schema.meal_plan.new_meal import CreatePlanEntry from mealie.schema.meal_plan.new_meal import CreatePlanEntry
from mealie.schema.recipe import Recipe from mealie.schema.recipe import Recipe
from mealie.schema.recipe.recipe_category import CategorySave, TagSave from mealie.schema.recipe.recipe_category import CategorySave, TagSave
from mealie.schema.recipe.recipe_ingredient import IngredientUnit, SaveIngredientFood, SaveIngredientUnit from mealie.schema.recipe.recipe_ingredient import (
IngredientUnit,
SaveIngredientFood,
SaveIngredientUnit,
)
from mealie.schema.recipe.recipe_tool import RecipeToolSave from mealie.schema.recipe.recipe_tool import RecipeToolSave
from mealie.schema.response.pagination import OrderByNullPosition, OrderDirection, PaginationQuery from mealie.schema.response.pagination import (
OrderByNullPosition,
OrderDirection,
PaginationQuery,
)
from mealie.services.seeder.seeder_service import SeederService from mealie.services.seeder.seeder_service import SeederService
from tests.utils import api_routes from tests.utils import api_routes
from tests.utils.factories import random_int, random_string from tests.utils.factories import random_int, random_string
@ -205,16 +213,27 @@ def test_pagination_filter_basic(query_units: tuple[RepositoryUnit, IngredientUn
def test_pagination_filter_null(database: AllRepositories, unique_user: TestUser): def test_pagination_filter_null(database: AllRepositories, unique_user: TestUser):
recipe_not_made_1 = database.recipes.create( recipe_not_made_1 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string()) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
)
) )
recipe_not_made_2 = database.recipes.create( recipe_not_made_2 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string()) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
)
) )
# give one recipe a last made date # give one recipe a last made date
recipe_made = database.recipes.create( recipe_made = database.recipes.create(
Recipe( Recipe(
user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string(), last_made=datetime.now() user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
last_made=datetime.now(),
) )
) )
@ -294,22 +313,46 @@ def test_pagination_filter_in_advanced(database: AllRepositories, unique_user: T
# Bootstrap the database with recipes # Bootstrap the database with recipes
slug = random_string() slug = random_string()
recipe_0 = database.recipes.create( recipe_0 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug, tags=[]) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
tags=[],
)
) )
slug = random_string() slug = random_string()
recipe_1 = database.recipes.create( recipe_1 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug, tags=[tag_1]) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
tags=[tag_1],
)
) )
slug = random_string() slug = random_string()
recipe_2 = database.recipes.create( recipe_2 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug, tags=[tag_2]) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
tags=[tag_2],
)
) )
slug = random_string() slug = random_string()
recipe_1_2 = database.recipes.create( recipe_1_2 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug, tags=[tag_1, tag_2]) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
tags=[tag_1, tag_2],
)
) )
query = PaginationQuery(page=1, per_page=-1, query_filter=f"tags.name IN [{tag_1.name}]") query = PaginationQuery(page=1, per_page=-1, query_filter=f"tags.name IN [{tag_1.name}]")
@ -330,7 +373,11 @@ def test_pagination_filter_in_advanced(database: AllRepositories, unique_user: T
assert recipe_2.id in recipe_ids assert recipe_2.id in recipe_ids
assert recipe_1_2.id in recipe_ids assert recipe_1_2.id in recipe_ids
query = PaginationQuery(page=1, per_page=-1, query_filter=f"tags.name CONTAINS ALL [{tag_1.name}, {tag_2.name}]") query = PaginationQuery(
page=1,
per_page=-1,
query_filter=f"tags.name CONTAINS ALL [{tag_1.name}, {tag_2.name}]",
)
recipe_results = database.recipes.page_all(query).items recipe_results = database.recipes.page_all(query).items
assert len(recipe_results) == 1 assert len(recipe_results) == 1
recipe_ids = {recipe.id for recipe in recipe_results} recipe_ids = {recipe.id for recipe in recipe_results}
@ -373,14 +420,29 @@ def test_pagination_filter_like(query_units: tuple[RepositoryUnit, IngredientUni
def test_pagination_filter_keyword_namespace_conflict(database: AllRepositories, unique_user: TestUser): def test_pagination_filter_keyword_namespace_conflict(database: AllRepositories, unique_user: TestUser):
recipe_rating_1 = database.recipes.create( recipe_rating_1 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string(), rating=1) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
rating=1,
)
) )
recipe_rating_2 = database.recipes.create( recipe_rating_2 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string(), rating=2) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
rating=2,
)
) )
recipe_rating_3 = database.recipes.create( recipe_rating_3 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=random_string(), rating=3) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=random_string(),
rating=3,
)
) )
recipe_repo = database.recipes.by_group(unique_user.group_id) # type: ignore recipe_repo = database.recipes.by_group(unique_user.group_id) # type: ignore
@ -415,7 +477,12 @@ def test_pagination_filter_logical_namespace_conflict(database: AllRepositories,
# Bootstrap the database with recipes # Bootstrap the database with recipes
slug = random_string() slug = random_string()
recipe_category_0 = database.recipes.create( recipe_category_0 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
)
) )
slug = random_string() slug = random_string()
@ -451,7 +518,7 @@ def test_pagination_filter_logical_namespace_conflict(database: AllRepositories,
def test_pagination_filter_datetimes( def test_pagination_filter_datetimes(
query_units: tuple[RepositoryUnit, IngredientUnit, IngredientUnit, IngredientUnit] query_units: tuple[RepositoryUnit, IngredientUnit, IngredientUnit, IngredientUnit],
): ):
# units are created in order with increasing createdAt values # units are created in order with increasing createdAt values
units_repo, unit_1, unit_2, unit_3 = query_units units_repo, unit_1, unit_2, unit_3 = query_units
@ -544,7 +611,11 @@ def test_pagination_filter_datetimes(
assert len(unit_ids) == 0 assert len(unit_ids) == 0
@pytest.mark.parametrize("order_direction", [OrderDirection.asc, OrderDirection.desc], ids=["ascending", "descending"]) @pytest.mark.parametrize(
"order_direction",
[OrderDirection.asc, OrderDirection.desc],
ids=["ascending", "descending"],
)
def test_pagination_order_by_multiple( def test_pagination_order_by_multiple(
database: AllRepositories, unique_user: TestUser, order_direction: OrderDirection database: AllRepositories, unique_user: TestUser, order_direction: OrderDirection
): ):
@ -571,7 +642,10 @@ def test_pagination_order_by_multiple(
) )
sorted_units = database.ingredient_units.create_many(units_to_create) sorted_units = database.ingredient_units.create_many(units_to_create)
sorted_units.sort(key=lambda x: (x.abbreviation, x.description), reverse=order_direction is OrderDirection.desc) sorted_units.sort(
key=lambda x: (x.abbreviation, x.description),
reverse=order_direction is OrderDirection.desc,
)
query = database.ingredient_units.page_all( query = database.ingredient_units.page_all(
PaginationQuery( PaginationQuery(
@ -602,7 +676,10 @@ def test_pagination_order_by_multiple(
], ],
) )
def test_pagination_order_by_multiple_directions( def test_pagination_order_by_multiple_directions(
database: AllRepositories, unique_user: TestUser, order_by_str: str, order_direction: OrderDirection database: AllRepositories,
unique_user: TestUser,
order_by_str: str,
order_direction: OrderDirection,
): ):
current_time = datetime.now() current_time = datetime.now()
@ -695,7 +772,11 @@ def test_pagination_order_by_doesnt_filter(database: AllRepositories, unique_use
) )
query = database.ingredient_foods.by_group(unique_user.group_id).page_all( query = database.ingredient_foods.by_group(unique_user.group_id).page_all(
PaginationQuery(per_page=-1, query_filter=f"created_at>{current_time.isoformat()}", order_by="label.name") PaginationQuery(
per_page=-1,
query_filter=f"created_at>{current_time.isoformat()}",
order_by="label.name",
)
) )
assert len(query.items) == 2 assert len(query.items) == 2
found_ids = {item.id for item in query.items} found_ids = {item.id for item in query.items}
@ -758,7 +839,11 @@ def test_pagination_order_by_nulls(
def test_pagination_shopping_list_items_with_labels(database: AllRepositories, unique_user: TestUser): def test_pagination_shopping_list_items_with_labels(database: AllRepositories, unique_user: TestUser):
# create a shopping list and populate it with some items with labels, and some without labels # create a shopping list and populate it with some items with labels, and some without labels
shopping_list = database.group_shopping_lists.create( shopping_list = database.group_shopping_lists.create(
ShoppingListSave(name=random_string(), group_id=unique_user.group_id, user_id=unique_user.user_id) ShoppingListSave(
name=random_string(),
group_id=unique_user.group_id,
user_id=unique_user.user_id,
)
) )
labels = database.group_multi_purpose_labels.create_many( labels = database.group_multi_purpose_labels.create_many(
@ -831,7 +916,10 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
mealplan_today = CreatePlanEntry(date=today, entry_type="breakfast", title=random_string(), text=random_string()) mealplan_today = CreatePlanEntry(date=today, entry_type="breakfast", title=random_string(), text=random_string())
mealplan_tomorrow = CreatePlanEntry( mealplan_tomorrow = CreatePlanEntry(
date=tomorrow, entry_type="breakfast", title=random_string(), text=random_string() date=tomorrow,
entry_type="breakfast",
title=random_string(),
text=random_string(),
) )
for mealplan_to_create in [mealplan_today, mealplan_tomorrow]: for mealplan_to_create in [mealplan_today, mealplan_tomorrow]:
@ -841,7 +929,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert response.status_code == 201 assert response.status_code == 201
## Yesterday ## Yesterday
params = {f"page": 1, "perPage": -1, "queryFilter": f"date >= {yesterday.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date >= {yesterday.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -851,7 +943,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert mealplan_today.title in fetched_mealplan_titles assert mealplan_today.title in fetched_mealplan_titles
assert mealplan_tomorrow.title in fetched_mealplan_titles assert mealplan_tomorrow.title in fetched_mealplan_titles
params = {f"page": 1, "perPage": -1, "queryFilter": f"date > {yesterday.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date > {yesterday.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -862,7 +958,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert mealplan_tomorrow.title in fetched_mealplan_titles assert mealplan_tomorrow.title in fetched_mealplan_titles
## Today ## Today
params = {f"page": 1, "perPage": -1, "queryFilter": f"date >= {today.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date >= {today.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -872,7 +972,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert mealplan_today.title in fetched_mealplan_titles assert mealplan_today.title in fetched_mealplan_titles
assert mealplan_tomorrow.title in fetched_mealplan_titles assert mealplan_tomorrow.title in fetched_mealplan_titles
params = {f"page": 1, "perPage": -1, "queryFilter": f"date > {today.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date > {today.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -883,7 +987,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert mealplan_tomorrow.title in fetched_mealplan_titles assert mealplan_tomorrow.title in fetched_mealplan_titles
## Tomorrow ## Tomorrow
params = {f"page": 1, "perPage": -1, "queryFilter": f"date >= {tomorrow.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date >= {tomorrow.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -893,7 +1001,11 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert mealplan_today.title not in fetched_mealplan_titles assert mealplan_today.title not in fetched_mealplan_titles
assert mealplan_tomorrow.title in fetched_mealplan_titles assert mealplan_tomorrow.title in fetched_mealplan_titles
params = {f"page": 1, "perPage": -1, "queryFilter": f"date > {tomorrow.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date > {tomorrow.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -901,13 +1013,21 @@ def test_pagination_filter_dates(api_client: TestClient, unique_user: TestUser):
assert len(response_json["items"]) == 0 assert len(response_json["items"]) == 0
## Day After Tomorrow ## Day After Tomorrow
params = {f"page": 1, "perPage": -1, "queryFilter": f"date >= {day_after_tomorrow.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date >= {day_after_tomorrow.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
assert len(response_json["items"]) == 0 assert len(response_json["items"]) == 0
params = {f"page": 1, "perPage": -1, "queryFilter": f"date > {day_after_tomorrow.strftime('%Y-%m-%d')}"} params = {
f"page": 1,
"perPage": -1,
"queryFilter": f"date > {day_after_tomorrow.strftime('%Y-%m-%d')}",
}
response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token) response = api_client.get(api_routes.groups_mealplans, params=params, headers=unique_user.token)
assert response.status_code == 200 assert response.status_code == 200
response_json = response.json() response_json = response.json()
@ -974,7 +1094,12 @@ def test_pagination_filter_advanced_frontend_sort(database: AllRepositories, uni
# Bootstrap the database with recipes # Bootstrap the database with recipes
slug = random_string() slug = random_string()
recipe_ct0_tg0_tl0 = database.recipes.create( recipe_ct0_tg0_tl0 = database.recipes.create(
Recipe(user_id=unique_user.user_id, group_id=unique_user.group_id, name=slug, slug=slug) Recipe(
user_id=unique_user.user_id,
group_id=unique_user.group_id,
name=slug,
slug=slug,
)
) )
slug = random_string() slug = random_string()
@ -1111,17 +1236,26 @@ def test_pagination_filter_advanced_frontend_sort(database: AllRepositories, uni
[ [
pytest.param('(name="test name" AND useAbbreviation=f))', id="unbalanced parenthesis"), pytest.param('(name="test name" AND useAbbreviation=f))', id="unbalanced parenthesis"),
pytest.param('id="this is not a valid UUID"', id="invalid UUID"), pytest.param('id="this is not a valid UUID"', id="invalid UUID"),
pytest.param('createdAt="this is not a valid datetime format"', id="invalid datetime format"), pytest.param(
'createdAt="this is not a valid datetime format"',
id="invalid datetime format",
),
pytest.param('name IS "test name"', id="IS can only be used with NULL or NONE"), pytest.param('name IS "test name"', id="IS can only be used with NULL or NONE"),
pytest.param('name IS NOT "test name"', id="IS NOT can only be used with NULL or NONE"), pytest.param('name IS NOT "test name"', id="IS NOT can only be used with NULL or NONE"),
pytest.param('name IN "test name"', id="IN must use a list of values"), pytest.param('name IN "test name"', id="IN must use a list of values"),
pytest.param('name NOT IN "test name"', id="NOT IN must use a list of values"), pytest.param('name NOT IN "test name"', id="NOT IN must use a list of values"),
pytest.param('name CONTAINS ALL "test name"', id="CONTAINS ALL must use a list of values"), pytest.param('name CONTAINS ALL "test name"', id="CONTAINS ALL must use a list of values"),
pytest.param('createdAt LIKE "2023-02-25"', id="LIKE is only valid for string columns"), pytest.param('createdAt LIKE "2023-02-25"', id="LIKE is only valid for string columns"),
pytest.param('createdAt NOT LIKE "2023-02-25"', id="NOT LIKE is only valid for string columns"), pytest.param(
'createdAt NOT LIKE "2023-02-25"',
id="NOT LIKE is only valid for string columns",
),
pytest.param('badAttribute="test value"', id="invalid attribute"), pytest.param('badAttribute="test value"', id="invalid attribute"),
pytest.param('group.badAttribute="test value"', id="bad nested attribute"), pytest.param('group.badAttribute="test value"', id="bad nested attribute"),
pytest.param('group.preferences.badAttribute="test value"', id="bad double nested attribute"), pytest.param(
'group.preferences.badAttribute="test value"',
id="bad double nested attribute",
),
], ],
) )
def test_malformed_query_filters(api_client: TestClient, unique_user: TestUser, qf: str): def test_malformed_query_filters(api_client: TestClient, unique_user: TestUser, qf: str):
@ -1162,7 +1296,11 @@ def test_pagination_filter_nested(api_client: TestClient, user_tuple: list[TestU
# query timeline events with a double nested recipe.user filter # query timeline events with a double nested recipe.user filter
for i, user in enumerate(user_tuple): for i, user in enumerate(user_tuple):
params = {"page": 1, "perPage": -1, "queryFilter": f'recipe.user.id="{user.user_id}"'} params = {
"page": 1,
"perPage": -1,
"queryFilter": f'recipe.user.id="{user.user_id}"',
}
response = api_client.get(api_routes.recipes_timeline_events, params=params, headers=user.token) response = api_client.get(api_routes.recipes_timeline_events, params=params, headers=user.token)
assert response.status_code == 200 assert response.status_code == 200