Skip to content

Commit c3c6bd6

Browse files
added test
1 parent ff11528 commit c3c6bd6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/integration_tests/user_recipe_tests/test_recipe_crud.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from mealie.repos.repository_factory import AllRepositories
2020
from mealie.schema.recipe.recipe import RecipeCategory, RecipeSummary, RecipeTag
21+
from mealie.schema.recipe.recipe_notes import RecipeNote
2122
from mealie.services.recipe.recipe_data_service import RecipeDataService
2223
from mealie.services.scraper.recipe_scraper import DEFAULT_SCRAPER_STRATEGIES
2324
from tests import data, utils
@@ -610,6 +611,42 @@ def test_rename(api_client: TestClient, recipe_data: RecipeSiteTestCase, unique_
610611
recipe_data.expected_slug = new_slug
611612

612613

614+
def test_remove_notes(api_client: TestClient, unique_user: TestUser):
615+
# create recipe
616+
recipe_create_url = api_routes.recipes
617+
recipe_create_data = {"name": random_string()}
618+
response = api_client.post(recipe_create_url, headers=unique_user.token, json=recipe_create_data)
619+
assert response.status_code == 201
620+
recipe_slug: str = response.json()
621+
622+
# get recipe and add a note
623+
recipe_url = api_routes.recipes_slug(recipe_slug)
624+
response = api_client.get(recipe_url, headers=unique_user.token)
625+
assert response.status_code == 200
626+
627+
recipe = json.loads(response.text)
628+
recipe["notes"] = [RecipeNote(title=random_string(), text=random_string()).dict()]
629+
response = api_client.put(recipe_url, json=recipe, headers=unique_user.token)
630+
assert response.status_code == 200
631+
632+
# get recipe and remove the note
633+
response = api_client.get(recipe_url, headers=unique_user.token)
634+
assert response.status_code == 200
635+
636+
recipe = json.loads(response.text)
637+
assert len(recipe.get("notes", [])) == 1
638+
recipe["notes"] = []
639+
response = api_client.put(recipe_url, json=recipe, headers=unique_user.token)
640+
assert response.status_code == 200
641+
642+
# verify the note is removed
643+
response = api_client.get(recipe_url, headers=unique_user.token)
644+
assert response.status_code == 200
645+
646+
recipe = json.loads(response.text)
647+
assert len(recipe.get("notes", [])) == 0
648+
649+
613650
@pytest.mark.parametrize("recipe_data", recipe_test_data)
614651
def test_delete(api_client: TestClient, recipe_data: RecipeSiteTestCase, unique_user: TestUser):
615652
response = api_client.delete(api_routes.recipes_slug(recipe_data.expected_slug), headers=unique_user.token)

0 commit comments

Comments
 (0)