mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-06 05:55:23 +02:00
fix: Lint Python code with ruff (#3799)
This commit is contained in:
parent
65ece35966
commit
432914e310
41 changed files with 112 additions and 120 deletions
|
@ -1,5 +1,5 @@
|
|||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
from typing import Generator
|
||||
|
||||
import pytest
|
||||
import sqlalchemy
|
||||
|
|
|
@ -4,8 +4,8 @@ import os
|
|||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
from typing import Generator
|
||||
from uuid import uuid4
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
@ -489,9 +489,9 @@ def test_duplicate(api_client: TestClient, recipe_data: RecipeSiteTestCase, uniq
|
|||
|
||||
# Ingredients should have the same texts, but different ids
|
||||
assert duplicate_recipe["recipeIngredient"] != initial_recipe["recipeIngredient"]
|
||||
assert list(map(lambda i: i["note"], duplicate_recipe["recipeIngredient"])) == list(
|
||||
map(lambda i: i["note"], initial_recipe["recipeIngredient"])
|
||||
)
|
||||
assert [i["note"] for i in duplicate_recipe["recipeIngredient"]] == [
|
||||
i["note"] for i in initial_recipe["recipeIngredient"]
|
||||
]
|
||||
|
||||
previous_categories = initial_recipe["recipeCategory"]
|
||||
assert duplicate_recipe["recipeCategory"] == previous_categories
|
||||
|
@ -748,21 +748,21 @@ def test_get_recipes_organizer_filter(
|
|||
# get recipes by organizer
|
||||
if organizer_type == "tags":
|
||||
organizer = random.choice(tags)
|
||||
expected_recipe_ids = set(
|
||||
expected_recipe_ids = {
|
||||
str(recipe.id) for recipe in recipes if organizer.id in [tag.id for tag in recipe.tags or []]
|
||||
)
|
||||
}
|
||||
elif organizer_type == "categories":
|
||||
organizer = random.choice(categories)
|
||||
expected_recipe_ids = set(
|
||||
expected_recipe_ids = {
|
||||
str(recipe.id)
|
||||
for recipe in recipes
|
||||
if organizer.id in [category.id for category in recipe.recipe_category or []]
|
||||
)
|
||||
}
|
||||
elif organizer_type == "tools":
|
||||
organizer = random.choice(tools)
|
||||
expected_recipe_ids = set(
|
||||
expected_recipe_ids = {
|
||||
str(recipe.id) for recipe in recipes if organizer.id in [tool.id for tool in recipe.tools or []]
|
||||
)
|
||||
}
|
||||
else:
|
||||
raise ValueError(f"Unknown organizer type: {organizer_type}")
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from io import BytesIO
|
||||
import json
|
||||
import zipfile
|
||||
from io import BytesIO
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ def test_recipe_ingredients_parser_nlp(api_client: TestClient, unique_user: Test
|
|||
response = api_client.post(api_routes.parser_ingredients, json=payload, headers=unique_user.token)
|
||||
assert response.status_code == 200
|
||||
|
||||
for api_ingredient, test_ingredient in zip(response.json(), test_ingredients):
|
||||
for api_ingredient, test_ingredient in zip(response.json(), test_ingredients, strict=False):
|
||||
assert_ingredient(api_ingredient, test_ingredient)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import random
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
from uuid import UUID
|
||||
|
||||
import pytest
|
||||
|
@ -71,8 +71,8 @@ def test_user_recipe_favorites(
|
|||
ratings = response.json()["ratings"]
|
||||
|
||||
assert len(ratings) == len(recipes_to_favorite)
|
||||
fetched_recipe_ids = set(rating["recipeId"] for rating in ratings)
|
||||
favorited_recipe_ids = set(str(recipe.id) for recipe in recipes_to_favorite)
|
||||
fetched_recipe_ids = {rating["recipeId"] for rating in ratings}
|
||||
favorited_recipe_ids = {str(recipe.id) for recipe in recipes_to_favorite}
|
||||
assert fetched_recipe_ids == favorited_recipe_ids
|
||||
|
||||
# remove favorites
|
||||
|
@ -87,8 +87,8 @@ def test_user_recipe_favorites(
|
|||
ratings = response.json()["ratings"]
|
||||
|
||||
assert len(ratings) == len(recipes_to_favorite) - len(recipe_favorites_to_remove)
|
||||
fetched_recipe_ids = set(rating["recipeId"] for rating in ratings)
|
||||
removed_recipe_ids = set(str(recipe.id) for recipe in recipe_favorites_to_remove)
|
||||
fetched_recipe_ids = {rating["recipeId"] for rating in ratings}
|
||||
removed_recipe_ids = {str(recipe.id) for recipe in recipe_favorites_to_remove}
|
||||
assert fetched_recipe_ids == favorited_recipe_ids - removed_recipe_ids
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
import pytest
|
||||
import sqlalchemy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue