From 6cf1c8cd27495612b7c8b2184645d08652ffd0a6 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 6 Oct 2024 01:01:07 +0330 Subject: [PATCH] fix : check_ratio_limits updated --- mycoffee/functions.py | 8 ++++---- test/functions_test.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mycoffee/functions.py b/mycoffee/functions.py index 068eabd..09dc9eb 100644 --- a/mycoffee/functions.py +++ b/mycoffee/functions.py @@ -38,7 +38,7 @@ def print_result(params): params["coffee_ratio"], params["water_ratio"], params["info"])) - if check_ratio_limits(params): + if not check_ratio_limits(params): ratio_lower_limit = METHODS_MAP[method]["ratio_lower_limit"] ratio_upper_limit = METHODS_MAP[method]["ratio_upper_limit"] print(RATIO_WARNING_MESSAGE.format(method, str(ratio_lower_limit), str(ratio_upper_limit))) @@ -121,7 +121,7 @@ def check_ratio_limits(params): :param params: parameters :type params: dict - :return: result as bool (True --> the ratio is out of range) + :return: result as bool (False --> the ratio is out of range) """ method = params["method"] if "ratio_lower_limit" in METHODS_MAP[method] and "ratio_upper_limit" in METHODS_MAP[method]: @@ -129,8 +129,8 @@ def check_ratio_limits(params): ratio_lower_limit = METHODS_MAP[method]["ratio_lower_limit"] ratio_upper_limit = METHODS_MAP[method]["ratio_upper_limit"] if ratio < ratio_lower_limit or ratio > ratio_upper_limit: - return True - return False + return False + return True def calc_coffee(params): diff --git a/test/functions_test.py b/test/functions_test.py index b7a3bbd..5f2f237 100644 --- a/test/functions_test.py +++ b/test/functions_test.py @@ -26,7 +26,7 @@ >>> test_params = {"method":"v60", "cups":2, "coffee":30, "water":500, "coffee_ratio": 3, "water_ratio":50, "info":"", "digits":3} >>> test_params = filter_params(test_params) ->>> check_ratio_limits(test_params) == False +>>> check_ratio_limits(test_params) == True True >>> print_result(test_params) __ __ _ _ ___ _____ ____ ____ ____ ____ @@ -50,7 +50,7 @@ >>> test_params = {"method":"v60", "cups":2, "coffee":3, "water":500, "coffee_ratio": 6, "water_ratio":1000, "info":"", "digits":3} >>> test_params = filter_params(test_params) ->>> check_ratio_limits(test_params) == True +>>> check_ratio_limits(test_params) == False True >>> print_result(test_params) __ __ _ _ ___ _____ ____ ____ ____ ____ @@ -75,7 +75,7 @@ [Warning] The ratio is not within the standard range. For `v60`, the ratio can be anywhere between `1/18` and `1/14` >>> test_params = {"method":"custom", "cups":2, "coffee":3, "water":500, "coffee_ratio": 6, "water_ratio":1000, "info":"", "digits":3} >>> test_params = filter_params(test_params) ->>> check_ratio_limits(test_params) == False +>>> check_ratio_limits(test_params) == True True >>> chemex_params = load_method_params("chemex") >>> chemex_params == {'info': 'Chemex method', 'water': 240, 'cups': 1, 'coffee_ratio': 1, 'water_ratio': 15, 'digits': 3}