Fakultas Ilmu Komputer UI

Commit d1a17c65 authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto
Browse files

Merge branch 'hotfix-PBI-2-ggl-formula' into 'staging'

Changed error message to be more descriptive

See merge request !47
parents af45d480 212e8e2a
Pipeline #73291 passed with stages
in 16 minutes and 9 seconds
......@@ -247,10 +247,10 @@ def get_food_consumed_score(choice):
def get_total_vegetable_and_fruit_score(vegetables_in_one_day, fruits_in_one_day):
if (vegetables_in_one_day < 1) or (vegetables_in_one_day > 5):
raise ValueError("Invalid vegetable choice number!")
raise ValueError(f"{vegetables_in_one_day}: Invalid vegetable choice number!")
if (fruits_in_one_day < 1) or (fruits_in_one_day > 5):
raise ValueError("Invalid fruit choice number!")
raise ValueError(f"{fruits_in_one_day}: Invalid fruit choice number!")
vegetable_score = get_food_consumed_score(vegetables_in_one_day)
fruit_score = get_food_consumed_score(fruits_in_one_day)
......@@ -262,7 +262,8 @@ def get_vegetable_and_fruit_sufficiency_response(
total_vegetable_and_fruit_score):
if (total_vegetable_and_fruit_score < 0) or (
total_vegetable_and_fruit_score > 8):
raise ValueError("Invalid total vegetable and fruit score!")
raise ValueError(f"{total_vegetable_and_fruit_score}: \
Invalid total vegetable and fruit score!")
if 0 <= total_vegetable_and_fruit_score <= 4:
return VegetableAndFruitSufficiencyResponse.LACKING
......@@ -283,16 +284,16 @@ def get_total_sugar_salt_fat_score(
sweet_drinks_choice,
packaged_food_choice):
if (fried_food_choice < 1) or (fried_food_choice > 5):
raise ValueError("Invalid fried food choice number!")
raise ValueError(f"{fried_food_choice}: Invalid fried food choice number!")
if (sweet_snacks_choice < 1) or (sweet_snacks_choice > 5):
raise ValueError("Invalid sweet snacks choice number!")
raise ValueError(f"{sweet_snacks_choice}: Invalid sweet snacks choice number!")
if (sweet_drinks_choice < 1) or (sweet_drinks_choice > 5):
raise ValueError("Invalid sweet drinks choice number!")
raise ValueError(f"{sweet_drinks_choice}: Invalid sweet drinks choice number!")
if (packaged_food_choice < 1) or (packaged_food_choice > 5):
raise ValueError("Invalid packaged food choice number!")
raise ValueError(f"{packaged_food_choice}: Invalid packaged food choice number!")
fried_food_score = get_food_consumed_score(fried_food_choice)
sweet_snacks_score = get_food_consumed_score(sweet_snacks_choice)
......@@ -305,7 +306,8 @@ def get_total_sugar_salt_fat_score(
def get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score):
if (total_sugar_salt_fat_score < 0) or (total_sugar_salt_fat_score > 16):
raise ValueError("Invalid total sugar, salt, fat score!")
raise ValueError(f"{total_sugar_salt_fat_score}: \
Invalid total sugar, salt, fat score!")
if 0 <= total_sugar_salt_fat_score <= 7:
return SugarSaltFatProblemResponse.CONTROLLED
......@@ -321,7 +323,7 @@ def get_sugar_salt_fat_diet_recommendation(sugar_salt_fat_problem_response):
def get_large_meal_diet_recommendation(large_meal_in_one_day):
if (large_meal_in_one_day < 1) or (large_meal_in_one_day > 4):
raise ValueError("Invalid large meal choice number!")
raise ValueError(f"{large_meal_in_one_day}: Invalid large meal choice number!")
if large_meal_in_one_day == 1:
return LargeMealDietRecommendation.ONCE_A_DAY
......@@ -334,7 +336,7 @@ def get_large_meal_diet_recommendation(large_meal_in_one_day):
def get_snacks_diet_recommendation(snacks_in_one_day):
if (snacks_in_one_day < 1) or (snacks_in_one_day > 5):
raise ValueError("Invalid snacks choice number!")
raise ValueError(f"{snacks_in_one_day}: Invalid snacks choice number!")
if snacks_in_one_day == 1:
return SnacksDietRecommendation.NO_SNACK
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment