Skip to content

Commit

Permalink
added new test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKassab committed Aug 21, 2024
1 parent ad32320 commit 6c06cff
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/recipe/tests/test_recipe_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6c06cff

Please sign in to comment.