Fix for shopping list recipe delete route (#1954)

* fixed broken types

* changed remove recipe route from delete to post
This commit is contained in:
Michael Genson
2022-12-31 01:09:22 -06:00
committed by GitHub
parent 46cc3898ab
commit c4eebaccca
5 changed files with 22 additions and 14 deletions

View File

@@ -202,8 +202,9 @@ def test_shopping_lists_remove_recipe(
assert item["note"] in known_ingredients
# Remove Recipe
response = api_client.delete(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), headers=unique_user.token
response = api_client.post(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id),
headers=unique_user.token,
)
# Get List and Check for Ingredients
@@ -241,8 +242,9 @@ def test_shopping_lists_remove_recipe_multiple_quantity(
assert item["note"] in known_ingredients
# Remove Recipe
response = api_client.delete(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id), headers=unique_user.token
response = api_client.post(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id),
headers=unique_user.token,
)
# Get List and Check for Ingredients
@@ -271,7 +273,7 @@ def test_shopping_list_remove_recipe_scale(
recipe = recipe_ingredient_only
recipe_initital_scale = 100
payload = {"recipeIncrementQuantity": recipe_initital_scale}
payload: dict = {"recipeIncrementQuantity": recipe_initital_scale}
# first add a bunch of quantity to the list
response = api_client.post(
@@ -299,8 +301,8 @@ def test_shopping_list_remove_recipe_scale(
recipe_expected_scale = recipe_initital_scale - recipe_decrement_scale
# remove some of the recipes
response = api_client.delete(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id),
response = api_client.post(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id),
headers=unique_user.token,
json=payload,
)
@@ -366,8 +368,8 @@ def test_recipe_decrement_max(
# now remove way too many instances of the recipe
payload = {"recipeDecrementQuantity": recipe_scale * 100}
response = api_client.delete(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id(sample_list.id, recipe.id),
response = api_client.post(
api_routes.groups_shopping_lists_item_id_recipe_recipe_id_delete(sample_list.id, recipe.id),
headers=unique_user.token,
json=payload,
)

View File

@@ -279,6 +279,11 @@ def groups_shopping_lists_item_id_recipe_recipe_id(item_id, recipe_id):
return f"{prefix}/groups/shopping/lists/{item_id}/recipe/{recipe_id}"
def groups_shopping_lists_item_id_recipe_recipe_id_delete(item_id, recipe_id):
"""`/api/groups/shopping/lists/{item_id}/recipe/{recipe_id}/delete`"""
return f"{prefix}/groups/shopping/lists/{item_id}/recipe/{recipe_id}/delete"
def groups_webhooks_item_id(item_id):
"""`/api/groups/webhooks/{item_id}`"""
return f"{prefix}/groups/webhooks/{item_id}"

View File

@@ -1,7 +1,7 @@
from requests import Response
from httpx import Response
def assert_ignore_keys(dict1: dict, dict2: dict, ignore_keys: list = None) -> None:
def assert_ignore_keys(dict1: dict, dict2: dict, ignore_keys: list | None = None) -> None:
"""
Itterates through a list of keys and checks if they are in the the provided ignore_keys list,
if they are not in the ignore_keys list, it checks the value of the key in the provided against