From f83daf154f862b1c762649e01db870c99f70005d Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 1 Jan 2025 08:22:49 +0100 Subject: [PATCH] removed tests for no longer existing signal --- .../tests/api/test_api_shopping_recipe.py | 113 ------------------ 1 file changed, 113 deletions(-) diff --git a/cookbook/tests/api/test_api_shopping_recipe.py b/cookbook/tests/api/test_api_shopping_recipe.py index 2024c696da..ac5fb80e4c 100644 --- a/cookbook/tests/api/test_api_shopping_recipe.py +++ b/cookbook/tests/api/test_api_shopping_recipe.py @@ -97,119 +97,6 @@ def test_shopping_recipe_method(request, arg, recipe, sle_count, u1_s1, u2_s1): assert r.status_code == 405 -@pytest.mark.parametrize("recipe, sle_count", [ - ({}, 10), - # shopping list from recipe with StepRecipe - ({'steps__recipe_count': 1}, 20), - # shopping list from recipe with food recipe - ({'steps__food_recipe_count': {'step': 0, 'count': 1}}, 19), - # shopping list from recipe with StepRecipe and food recipe - ({'steps__food_recipe_count': {'step': 0, 'count': 1}, 'steps__recipe_count': 1}, 29), -], indirect=['recipe']) -@pytest.mark.parametrize("use_mealplan", [(False), (True), ]) -def test_shopping_recipe_edit(request, recipe, sle_count, use_mealplan, u1_s1, u2_s1): - # tests editing shopping list via recipe or mealplan - with scopes_disabled(): - user = auth.get_user(u1_s1) - user2 = auth.get_user(u2_s1) - user.userpreference.mealplan_autoinclude_related = True - user.userpreference.mealplan_autoadd_shopping = True - user.userpreference.shopping_share.add(user2) - user.userpreference.save() - - if use_mealplan: - mealplan = MealPlanFactory( - space=recipe.space, created_by=user, servings=recipe.servings, recipe=recipe) - else: - u1_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id})) - r = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content) - assert [x['created_by']['id'] for x in r['results']].count(user.id) == sle_count - all_ing = list(ShoppingListEntry.objects.filter(list_recipe__recipe=recipe).all().values_list('ingredient', flat=True)) - keep_ing = all_ing[1:-1] # remove first and last element - del keep_ing[int(len(keep_ing) / 2)] # remove a middle element - list_recipe = r['results'][0]['list_recipe'] - amount_sum = sum([x['amount'] for x in r['results']]) - - # test modifying shopping list as different user - # test increasing servings size of recipe shopping list - if use_mealplan: - mealplan.servings = 2 * recipe.servings - mealplan.save() - else: - u2_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id}), - {'list_recipe': list_recipe, 'servings': 2 * recipe.servings}, - content_type='application/json' - ) - r = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content) - assert sum([x['amount'] for x in r['results']]) == amount_sum * 2 - assert r['count'] == sle_count - assert json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count - - # testing decreasing servings size of recipe shopping list - if use_mealplan: - mealplan.servings = .5 * recipe.servings - mealplan.save() - else: - u1_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id}), - {'list_recipe': list_recipe, 'servings': .5 * recipe.servings}, - content_type='application/json' - ) - r = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content) - assert sum([x['amount'] for x in r['results']]) == amount_sum * .5 - assert r['count'] == sle_count - assert json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count - - # test removing 3 items from shopping list - u2_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id}), - {'list_recipe': list_recipe, 'ingredients': keep_ing}, - content_type='application/json' - ) - r = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content) - assert r['count'] == sle_count - 3 - assert json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count - 3 - - # add all ingredients to existing shopping list - don't change serving size - u2_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id}), - {'list_recipe': list_recipe, 'ingredients': all_ing}, - content_type='application/json' - ) - r = json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content) - assert sum([x['amount'] for x in r['results']]) == amount_sum * .5 - assert r['count'] == sle_count - assert json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count - - -@pytest.mark.parametrize("user2, sle_count", [ - ({'mealplan_autoadd_shopping': False}, (0, 18)), - ({'mealplan_autoinclude_related': False}, (9, 9)), - ({'mealplan_autoexclude_onhand': False}, (20, 20)), - ({'mealplan_autoexclude_onhand': False, - 'mealplan_autoinclude_related': False}, (10, 10)), -], indirect=['user2']) -@pytest.mark.parametrize("use_mealplan", [(False), (True), ]) -@pytest.mark.parametrize("recipe", [({'steps__recipe_count': 1})], indirect=['recipe']) -def test_shopping_recipe_userpreference(recipe, sle_count, use_mealplan, user2): - with scopes_disabled(): - user = auth.get_user(user2) - # setup recipe with 10 ingredients, 1 step recipe with 10 ingredients, 2 food onhand(from recipe and step_recipe) - ingredients = Ingredient.objects.filter(step__recipe=recipe) - food = Food.objects.get(id=ingredients[2].food.id) - food.onhand_users.add(user) - food.save() - food = recipe.steps.exclude(step_recipe=None).first().step_recipe.steps.first().ingredients.first().food - food = Food.objects.get(id=food.id) - food.onhand_users.add(user) - food.save() - - if use_mealplan: - MealPlanFactory( - space=recipe.space, created_by=user, servings=recipe.servings, recipe=recipe) - assert json.loads(user2.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count[0] - else: - user2.put(reverse(SHOPPING_RECIPE_URL, args={recipe.id})) - assert json.loads(user2.get(reverse(SHOPPING_LIST_URL)).content)['count'] == sle_count[1] - - def test_shopping_recipe_mixed_authors(u1_s1, u2_s1, space_1): with scopes_disabled(): user1 = auth.get_user(u1_s1)