Ejemplo n.º 1
0
 def test_add_recipe(self):
     new_recipe =  {
      "title":"My new Recipe!",
      "_slug": "my-new-re\cipe",
      "description":"Devo chiedere?",
      "steps":[
         "take the seafood and wash it well",
         "start toasking the seafood with a bit of oil"
      ],
      "ingredients":[
         {
            "slug":"clambs",
            "amount":"20kg"
         }
        ]
      }
     self.assertTrue(libs.add_new_recipe(new_recipe, db= self.db))
     self.assertTrue(libs.get_recipe_by_slug(new_recipe['_slug'], db= self.db))
Ejemplo n.º 2
0
    def test_get_recipe_by_slug(self):
        recipe = libs.get_recipe_by_slug('linguine-al-pesto', db= self.db)
        self.assertTrue(type(recipe) == dict)

        recipe = libs.get_recipe_by_slug('abra cadabra', db= self.db)
        self.assertIsNone(recipe)
Ejemplo n.º 3
0
def getRecipeBySlug(slug):
    if slug:
        recipe = libs.get_recipe_by_slug(slug)
        if recipe:
            return 200, recipe
    return 404, {'error': 'recipe not found'}