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_inconsistent_db(): with pytest.raises(InconsistentBD): make_recipe_db("tests/test_data/test_inconsistent_db", 2)
def test_not_enough_recipes(conf): with pytest.raises(NotEnoughRecipesInDatabase): make_recipe_db(conf["recipe_folder"], 3)
def recipe_list(): return list(make_recipe_db("gimme_food/examples"))