update/remove tests

This commit is contained in:
Michael Genson 2025-07-11 16:36:41 +00:00
commit 3b82acb390
7 changed files with 2 additions and 78 deletions

View file

@ -44,7 +44,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1 cup unsalted butter, cut into cubes", "note": "1 cup unsalted butter, cut into cubes",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "ea3b6702-9532-4fbc-a40b-f99917831c26", "referenceId": "ea3b6702-9532-4fbc-a40b-f99917831c26",
@ -54,7 +53,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1 cup light brown sugar", "note": "1 cup light brown sugar",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "c5bbfefb-1e23-4ffd-af88-c0363a0fae82", "referenceId": "c5bbfefb-1e23-4ffd-af88-c0363a0fae82",
@ -64,7 +62,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1/2 cup granulated white sugar", "note": "1/2 cup granulated white sugar",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "034f481b-c426-4a17-b983-5aea9be4974b", "referenceId": "034f481b-c426-4a17-b983-5aea9be4974b",
@ -74,7 +71,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "2 large eggs", "note": "2 large eggs",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "37c1f796-3bdb-4856-859f-dbec90bc27e4", "referenceId": "37c1f796-3bdb-4856-859f-dbec90bc27e4",
@ -84,7 +80,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "2 tsp vanilla extract", "note": "2 tsp vanilla extract",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "85561ace-f249-401d-834c-e600a2f6280e", "referenceId": "85561ace-f249-401d-834c-e600a2f6280e",
@ -94,7 +89,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1/2 cup creamy peanut butter", "note": "1/2 cup creamy peanut butter",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "ac91bda0-e8a8-491a-976a-ae4e72418cfd", "referenceId": "ac91bda0-e8a8-491a-976a-ae4e72418cfd",
@ -104,7 +98,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1 tsp cornstarch", "note": "1 tsp cornstarch",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "4d1256b3-115e-4475-83cd-464fbc304cb0", "referenceId": "4d1256b3-115e-4475-83cd-464fbc304cb0",
@ -114,7 +107,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1 tsp baking soda", "note": "1 tsp baking soda",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "64627441-39f9-4ee3-8494-bafe36451d12", "referenceId": "64627441-39f9-4ee3-8494-bafe36451d12",
@ -124,7 +116,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1/2 tsp salt", "note": "1/2 tsp salt",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "7ae212d0-3cd1-44b0-899e-ec5bd91fd384", "referenceId": "7ae212d0-3cd1-44b0-899e-ec5bd91fd384",
@ -134,7 +125,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1 cup cake flour", "note": "1 cup cake flour",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "06967994-8548-4952-a8cc-16e8db228ebd", "referenceId": "06967994-8548-4952-a8cc-16e8db228ebd",
@ -144,7 +134,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "2 cups all-purpose flour", "note": "2 cups all-purpose flour",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "bdb33b23-c767-4465-acf8-3b8e79eb5691", "referenceId": "bdb33b23-c767-4465-acf8-3b8e79eb5691",
@ -154,7 +143,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "2 cups peanut butter chips", "note": "2 cups peanut butter chips",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "12ba0af8-affd-4fb2-9cca-6f1b3e8d3aef", "referenceId": "12ba0af8-affd-4fb2-9cca-6f1b3e8d3aef",
@ -164,7 +152,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"note": "1½ cups Reese's Pieces candies", "note": "1½ cups Reese's Pieces candies",
"unit": None, "unit": None,
"food": None, "food": None,
"disableAmount": True,
"quantity": 1, "quantity": 1,
"originalText": None, "originalText": None,
"referenceId": "4bdc0598-a3eb-41ee-8af0-4da9348fbfe2", "referenceId": "4bdc0598-a3eb-41ee-8af0-4da9348fbfe2",
@ -221,7 +208,6 @@ def recipe_data(name: str, slug: str, id: str, userId: str, groupId: str) -> dic
"showAssets": False, "showAssets": False,
"landscapeView": False, "landscapeView": False,
"disableComments": False, "disableComments": False,
"disableAmount": True,
"locked": False, "locked": False,
}, },
"assets": [], "assets": [],

View file

@ -12,7 +12,6 @@ def create_item(list_id: UUID4) -> dict:
"shopping_list_id": str(list_id), "shopping_list_id": str(list_id),
"checked": False, "checked": False,
"position": 0, "position": 0,
"is_food": False,
"note": random_string(10), "note": random_string(10),
"quantity": 1, "quantity": 1,
"unit_id": None, "unit_id": None,

View file

@ -49,7 +49,6 @@ def test_admin_update_household(api_client: TestClient, admin_user: TestUser, un
"recipeShowAssets": random_bool(), "recipeShowAssets": random_bool(),
"recipeLandscapeView": random_bool(), "recipeLandscapeView": random_bool(),
"recipeDisableComments": random_bool(), "recipeDisableComments": random_bool(),
"recipeDisableAmount": random_bool(),
}, },
} }

View file

@ -377,7 +377,6 @@ def test_get_suggested_recipes(
SaveIngredientFood(id=uuid4(), name=random_string(), group_id=unique_user.group_id) SaveIngredientFood(id=uuid4(), name=random_string(), group_id=unique_user.group_id)
) )
random_recipe.recipe_ingredient = [RecipeIngredient(food_id=known_food.id, food=known_food)] random_recipe.recipe_ingredient = [RecipeIngredient(food_id=known_food.id, food=known_food)]
random_recipe.settings.disable_amount = False
database.recipes.update(random_recipe.slug, random_recipe) database.recipes.update(random_recipe.slug, random_recipe)
## Try to find suggested recipes ## Try to find suggested recipes

View file

@ -205,7 +205,5 @@ def test_ingredient_display(
expected_components.append(note) expected_components.append(note)
expected_display_value = " ".join(c for c in expected_components if c) expected_display_value = " ".join(c for c in expected_components if c)
ingredient = RecipeIngredient( ingredient = RecipeIngredient(quantity=quantity, unit=unit, food=food, note=note, use_food=use_food)
quantity=quantity, unit=unit, food=food, note=note, use_food=use_food, disable_amount=not use_food
)
assert ingredient.display == expected_display_value assert ingredient.display == expected_display_value

View file

@ -48,7 +48,6 @@ def create_recipe(
*, *,
foods: list[IngredientFood] | None = None, foods: list[IngredientFood] | None = None,
tools: list[RecipeToolOut] | None = None, tools: list[RecipeToolOut] | None = None,
disable_amount: bool = False,
**kwargs, **kwargs,
): ):
if foods: if foods:
@ -63,7 +62,7 @@ def create_recipe(
name=kwargs.pop("name", random_string()), name=kwargs.pop("name", random_string()),
recipe_ingredient=ingredients, recipe_ingredient=ingredients,
tools=tools or [], tools=tools or [],
settings=RecipeSettings(disable_amount=disable_amount), settings=RecipeSettings(),
**kwargs, **kwargs,
) )
) )
@ -338,60 +337,6 @@ def test_include_recipes_with_no_tools(api_client: TestClient, unique_user: Test
unique_user.repos.recipes.delete(recipe.slug) unique_user.repos.recipes.delete(recipe.slug)
def test_ignore_recipes_with_ingredient_amounts_disabled_with_foods(api_client: TestClient, unique_user: TestUser):
known_food = create_food(unique_user)
recipe_with_amounts = create_recipe(unique_user, foods=[known_food])
recipe_without_amounts = create_recipe(unique_user, foods=[known_food], disable_amount=True)
try:
response = api_client.get(
api_routes.recipes_suggestions,
params={"maxMissingFoods": 0, "maxMissingTools": 0, "foods": [str(known_food.id)]},
headers=unique_user.token,
)
response.raise_for_status()
data = response.json()
assert {item["recipe"]["id"] for item in data["items"]} == {str(recipe_with_amounts.id)}
for item in data["items"]:
assert item["missingFoods"] == []
finally:
for recipe in [recipe_with_amounts, recipe_without_amounts]:
unique_user.repos.recipes.delete(recipe.slug)
def test_include_recipes_with_ingredient_amounts_disabled_without_foods(api_client: TestClient, unique_user: TestUser):
known_tool = create_tool(unique_user)
recipe_with_amounts = create_recipe(unique_user, tools=[known_tool])
recipe_without_amounts = create_recipe(unique_user, tools=[known_tool], disable_amount=True)
try:
response = api_client.get(
api_routes.recipes_suggestions,
params={
"maxMissingFoods": 0,
"maxMissingTools": 0,
"includeFoodsOnHand": False,
"tools": [str(known_tool.id)],
},
headers=unique_user.token,
)
response.raise_for_status()
data = response.json()
assert {item["recipe"]["id"] for item in data["items"]} == {
str(recipe_with_amounts.id),
str(recipe_without_amounts.id),
}
for item in data["items"]:
assert item["missingFoods"] == []
finally:
for recipe in [recipe_with_amounts, recipe_without_amounts]:
unique_user.repos.recipes.delete(recipe.slug)
def test_exclude_recipes_with_no_user_foods(api_client: TestClient, unique_user: TestUser): def test_exclude_recipes_with_no_user_foods(api_client: TestClient, unique_user: TestUser):
known_food = create_food(unique_user) known_food = create_food(unique_user)
food_on_hand = create_food(unique_user, on_hand=True) food_on_hand = create_food(unique_user, on_hand=True)

View file

@ -20,8 +20,6 @@ def test_shopping_list_ingredient_validation():
"updatedAt": "2024-02-26T18:29:46.190758", "updatedAt": "2024-02-26T18:29:46.190758",
}, },
"note": "", "note": "",
"isFood": True,
"disableAmount": False,
"shoppingListId": "dc8bce82-2da9-49f0-94e6-6d69d311490e", "shoppingListId": "dc8bce82-2da9-49f0-94e6-6d69d311490e",
"checked": False, "checked": False,
"position": 5, "position": 5,