コード例 #1
0
    def test_save_extracted_data(self):
        recipe_bo = RecipeBO()

        data = [{
            "title": "test recipe",
            "steps": ["step 1", "step 2", "step 3"],
            "ingredients": ["ingredient 1", "ingredient 2", "ingredient 3"]
        }]

        with open('data.json', 'w') as fp:
            json.dump(data, fp)

        f = open("data.json")
        data_id = recipe_bo.save_extracted_data(f.read())

        recipe = recipe_bo.list_full_recipe_by_id(data_id)

        self.assertEqual(recipe['title'], data[0]['title'])
        self.assertEqual(recipe['ingredients'], data[0]['ingredients'])
        self.assertEqual(recipe['steps'], data[0]['steps'])
コード例 #2
0
    def test_save_extracted_data(self):
        recipe_bo = RecipeBO()

        data = [
            {
                "title": "test recipe",
                "steps": ["step 1", "step 2", "step 3"],
                "ingredients": ["ingredient 1", "ingredient 2", "ingredient 3"],
            }
        ]

        with open("data.json", "w") as fp:
            json.dump(data, fp)

        f = open("data.json")
        data_id = recipe_bo.save_extracted_data(f.read())

        recipe = recipe_bo.list_full_recipe_by_id(data_id)

        self.assertEqual(recipe["title"], data[0]["title"])
        self.assertEqual(recipe["ingredients"], data[0]["ingredients"])
        self.assertEqual(recipe["steps"], data[0]["steps"])
コード例 #3
0
from fastfood.business.db_business import RecipeBO, StepBO, RecipeItemBO, UserBO, UserLikeRecipeBO
from fastfood.models.db import User
import json
from flask_restful import Resource, Api, reqparse, abort
from flask import request, g, jsonify

api = Api(app)
parser = reqparse.RequestParser()
parser.add_argument('login')
parser.add_argument('password')
parser.add_argument('role')
parser.add_argument('name')
parser.add_argument('user_id')
parser.add_argument('recipe_id')
parser.add_argument('action')
rbo = RecipeBO()
sbo = StepBO()
ribo = RecipeItemBO()
ubo = UserBO()
ulrbo = UserLikeRecipeBO()


class HelloWorld(Resource):
    def get(self):
        return {"Status API": "200 OK"}


class Recipes(Resource):
    def get(self, recipe_id=None):
        # check if it was passed items to be filtered
        if 'items' in request.args:
コード例 #4
0
# Run a test server.
from fastfood import app
from fastfood.business.db_business import RecipeBO, StepBO, RecipeItemBO
import json

rbo = RecipeBO()
f = open("items.json")
rbo.save_extracted_data(f.read())

# running the app now with gunicorn run:app

#ribo = RecipeItemBO()

#ribo.filter_by_items(['ovo', 'chocolate'])

#recipes = rbo.list_recipes_by_items(['ovo', 'chocolate'])
#print json.dumps(recipes)

#if __name__ == '__main__':
#	app.run(debug=True)