コード例 #1
0
ファイル: tests.py プロジェクト: PirosB3/PeopleCooks
 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']))
コード例 #2
0
ファイル: tests.py プロジェクト: PirosB3/PeopleCooks
 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))
コード例 #3
0
ファイル: __init__.py プロジェクト: PirosB3/PeopleCooks
def getIngredientbySlug(slug):
    if slug:
        ingredient= libs.get_ingredient_by_slug(slug)
        if ingredient:
            return 200, ingredient
    return 404, {'error': 'ingredient not found'}