def test_get_recipe_names_by_ingredient(self): ingredient = libs.get_ingredient_by_slug('pepper', db= self.db) self.assertTrue(ingredient) self.assertEqual('Pepper' ,ingredient['name']) self.assertEqual(2, len(ingredient['recipes']))
def test_add_ingredient(self): new_ingredient = { "name" : "Gnocchi" } self.assertTrue(libs.add_new_ingredient(new_ingredient, db= self.db)) self.assertTrue(libs.get_ingredient_by_slug('gnocchi', db= self.db))
def getIngredientbySlug(slug): if slug: ingredient= libs.get_ingredient_by_slug(slug) if ingredient: return 200, ingredient return 404, {'error': 'ingredient not found'}