1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-06 22:15:22 +02:00

fix: misused update over patch in last_update call (#2168)

* fixed mealplan timeline event task
fixed indentation to only look at one group at a time
changed grumpy update to happy patch

* updated pytest to catch this error

* I don't know how this got past the pre-commit
This commit is contained in:
Michael Genson 2023-02-23 16:10:47 -06:00 committed by GitHub
parent 6a1503d1f6
commit 6418a10428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 33 deletions

View file

@ -25,7 +25,8 @@ def test_new_mealplan_event(api_client: TestClient, unique_user: TestUser):
assert response.status_code == 201
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
recipe = RecipeSummary.parse_obj(response.json())
original_recipe_data: dict = response.json()
recipe = RecipeSummary.parse_obj(original_recipe_data)
recipe_id = recipe.id
assert recipe.last_made is None
@ -57,9 +58,28 @@ def test_new_mealplan_event(api_client: TestClient, unique_user: TestUser):
# make sure the recipe's last made date was updated
response = api_client.get(api_routes.recipes_slug(recipe_name), headers=unique_user.token)
recipe = RecipeSummary.parse_obj(response.json())
new_recipe_data: dict = response.json()
recipe = RecipeSummary.parse_obj(new_recipe_data)
assert recipe.last_made.date() == date.today() # type: ignore
# make sure nothing else was updated
for data in [original_recipe_data, new_recipe_data]:
data.pop("dateUpdated")
data.pop("updateAt")
data.pop("lastMade")
# instructions ids are generated randomly and aren't consistent between get requests
old_instructions: list[dict] = original_recipe_data.pop("recipeInstructions")
new_instructions: list[dict] = new_recipe_data.pop("recipeInstructions")
assert len(old_instructions) == len(new_instructions)
for old, new in zip(old_instructions, new_instructions, strict=True):
old.pop("id")
new.pop("id")
assert old == new
assert original_recipe_data == new_recipe_data
def test_new_mealplan_event_duplicates(api_client: TestClient, unique_user: TestUser):
recipe_name = random_string(length=25)