def test_create_basic_recipe(self):
    'Test creating recipe'
    payload = {'title': 'Chocolate cheesecake', 'time_minutes': 30, 'price': 5.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'])
    for key in payload.keys():
        self.assertEqual(payload[key], getattr(recipe, key))
Test creating recipe
def test_create_basic_recipe(self):
    
    payload = {'title': 'Chocolate cheesecake', 'time_minutes': 30, 'price': 5.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'])
    for key in payload.keys():
        self.assertEqual(payload[key], getattr(recipe, key))