From 6c06cff3483dfe4dbfa9c0c43390e511b3222084 Mon Sep 17 00:00:00 2001 From: andrewkassab Date: Wed, 21 Aug 2024 11:57:32 -0700 Subject: [PATCH] added new test --- app/recipe/tests/test_recipe_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/recipe/tests/test_recipe_api.py b/app/recipe/tests/test_recipe_api.py index 781fc50..0841bc5 100644 --- a/app/recipe/tests/test_recipe_api.py +++ b/app/recipe/tests/test_recipe_api.py @@ -358,3 +358,18 @@ def test_update_recipe_assign_ingredient(self): self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertIn(ingredient, recipe.ingredients.all()) + + def test_clear_recipe_ingredients(self): + ingredient = Ingredient.objects.create(user=self.user, name='Shrimp') + recipe = create_recipe(user=self.user) + recipe.ingredients.add(ingredient) + + payload = { + 'ingredients': [] + } + + url = detail_url(recipe.id) + res = self.client.patch(url, payload, format='json') + + self.assertEqual(res.status_code, status.HTTP_200_OK) + self.assertEqual(recipe.ingredients.count(), 0)