예제 #1
0
    def test_scrape_old_recipe(self):
        """ Test the scraping function when recipe is already in DB """

        Recipe.deleteRecipeById(recipe_id=39)
        db.session.commit()

        result = self.client.post('/importRecipe',
        data={"url":"http://cooking.nytimes.com/recipes/1015348-spicy-red-pepper-cranberry-relish"},
        follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('Error: This recipe has already been loaded', result.data)
예제 #2
0
    def test_scrape_old_recipe(self):
        """ Test the scraping function when recipe is already in DB """

        Recipe.deleteRecipeById(recipe_id=39)
        db.session.commit()

        result = self.client.post(
            '/importRecipe',
            data={
                "url":
                "http://cooking.nytimes.com/recipes/1015348-spicy-red-pepper-cranberry-relish"
            },
            follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('Error: This recipe has already been loaded',
                      result.data)
예제 #3
0
    def tearDown(self):  # It runs after each test
        print 'doing my teardown'
        User.query.filter_by(user_id=2).delete()
        Recipe.deleteRecipeById(recipe_id=39)

        db.session.commit()
예제 #4
0
def delete_recipe(recipeid):

    Recipe.deleteRecipeById(recipeid)
    db.session.commit()

    return redirect ("/recipes")
예제 #5
0
 def tearDown(self):# It runs after each test
     print 'doing my teardown'
     User.query.filter_by(user_id=2).delete()
     Recipe.deleteRecipeById(recipe_id=39)
     
     db.session.commit()