def test_create_recipe_with_ingredients(self):
    'Test creating recipe with ingredients'
    ingredient1 = sample_ingredient(user=self.user, name='Prawns')
    ingredient2 = sample_ingredient(user=self.user, name='Ginger')
    payload = {'title': 'Thai prawn red curry', 'ingredients': [ingredient1.id, ingredient2.id], 'time_minutes': 20, 'price': 7.0}
    res = self.client.post(RECIPE_URL, payload)
    self.assertEqual(res.status_code, status.HTTP_201_CREATED)
    recipe = Recipe.objects.get(id=res.data['id'])
    ingredients = recipe.ingredients.all()
    self.assertEqual(ingredients.count(), 2)
    self.assertIn(ingredient1, ingredients)
    self.assertIn(ingredient2, ingredients)
Test creating recipe with ingredients
def test_create_recipe_with_ingredients(self):
    
    ingredient1 = sample_ingredient(user=self.user, name='Prawns')
    ingredient2 = sample_ingredient(user=self.user, name='Ginger')
    payload = {'title': 'Thai prawn red curry', 'ingredients': [ingredient1.id, ingredient2.id], 'time_minutes': 20, 'price': 7.0}
    res = self.client.post(RECIPE_URL, payload)
    self.assertEqual(res.status_code, status.HTTP_201_CREATED)
    recipe = Recipe.objects.get(id=res.data['id'])
    ingredients = recipe.ingredients.all()
    self.assertEqual(ingredients.count(), 2)
    self.assertIn(ingredient1, ingredients)
    self.assertIn(ingredient2, ingredients)