def test_create_recipe_with_ingredients(self):
    'Test creating a recipe including ingredients'
    payload = {'name': 'Vegan Roast Dinner', 'description': 'Roasted potatoes and mushroom wellington with vegetables and gravy.', 'ingredients': [{'name': 'carrots'}, {'name': 'potatoes'}, {'name': 'mushrooms'}]}
    response = self.client.post(RECIPE_URL, payload, format='json')
    self.assertEqual(response.status_code, status.HTTP_201_CREATED)
    self.assertEqual(payload['name'], Recipe.objects.get(id=response.data['id']).name)
    self.assertEquals(len(response.data['ingredients']), len(payload['ingredients']))
Test creating a recipe including ingredients
def test_create_recipe_with_ingredients(self):
    
    payload = {'name': 'Vegan Roast Dinner', 'description': 'Roasted potatoes and mushroom wellington with vegetables and gravy.', 'ingredients': [{'name': 'carrots'}, {'name': 'potatoes'}, {'name': 'mushrooms'}]}
    response = self.client.post(RECIPE_URL, payload, format='json')
    self.assertEqual(response.status_code, status.HTTP_201_CREATED)
    self.assertEqual(payload['name'], Recipe.objects.get(id=response.data['id']).name)
    self.assertEquals(len(response.data['ingredients']), len(payload['ingredients']))