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")
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")
def test_one_ingredient(recipe_list): recipe_picker = RecipePicker(recipe_list, 1, ("Jordnötssmör",)) chosen_recipes = recipe_picker.get_recipes() assert len(chosen_recipes) == 1 assert chosen_recipes[0].name == "Fruktig kokosmjölksgryta"
def test_one_ingredient_two_recipes(recipe_list): recipe_picker = RecipePicker(recipe_list, 2, ("Jordnötssmör",)) chosen_recipes = recipe_picker.get_recipes() assert len(chosen_recipes) == 2