예제 #1
0
파일: app.py 프로젝트: timpara/gimme-food
def run_app(number_of_recipes, config, ingredient, debug):
    conf = read_config(config)
    log = get_logger(debug, conf["log_file"])
    print_banner(__version__)
    log.info(
        f"gimme-food started - version: {__version__}, config: {config}, " +
        f"number of recipes: {number_of_recipes}, ingredient: {ingredient}, debug: {debug}"
    )
    log.info(f"config values: {conf}")
    try:
        recipe_list = list(make_recipe_db(conf["recipe_folder"]))
    except RecipeNotInProperJsonFormat as e:
        log.error(e)
        sys.exit()
    recipe_picker = RecipePicker(recipe_list, number_of_recipes, ingredient)
    chosen_recipes = recipe_picker.get_recipes()
    present_result(chosen_recipes)
    log.info("gimme-food complete")
예제 #2
0
def run_app(number_of_recipes, config, ingredient, debug):
    conf = read_config(config)
    log = get_logger(debug, conf["log_file"])
    print_banner(__version__)
    print_safe_config = {k: v for k, v in conf.items() if k != "secret"}
    log.info(
        f"gimme-food started - version: {__version__}, config: {print_safe_config}, "
        +
        f"number of recipes: {number_of_recipes}, ingredient: {ingredient}, debug: {debug}"
    )
    try:
        recipe_list = make_recipe_db(conf["recipe_folder"], number_of_recipes)
    except (RecipeNotInProperJsonFormat, NotEnoughRecipesInDatabase,
            InconsistentBD) as e:
        log.error(e)
        sys.exit()
    recipe_picker = RecipePicker(recipe_list, number_of_recipes, ingredient)
    chosen_recipes = recipe_picker.get_recipes()
    present_result(chosen_recipes)
    log.info("gimme-food complete")
예제 #3
0
def test_inconsistent_db():
    with pytest.raises(InconsistentBD):
        make_recipe_db("tests/test_data/test_inconsistent_db", 2)
예제 #4
0
def test_not_enough_recipes(conf):
    with pytest.raises(NotEnoughRecipesInDatabase):
        make_recipe_db(conf["recipe_folder"], 3)
예제 #5
0
def recipe_list():
    return list(make_recipe_db("gimme_food/examples"))