Fakultas Ilmu Komputer UI

Commit cf58b94e authored by Ami's avatar Ami
Browse files

[RED] fixing the energy_needed_per_dine test in dietela_quiz/tests

parent 217d80c7
Pipeline #64666 failed with stage
in 6 minutes and 8 seconds
......@@ -119,34 +119,6 @@ class FormulaTest(TestCase):
self.assertEqual(recommendation_breakfast(2),BreakfastReponse.MED_BREAKFAST)
self.assertEqual(recommendation_breakfast(3),BreakfastReponse.HI_BREAKFAST)
def test_energy_needed_per_dine(self):
daily_energy_needs = 450
no_breakfast = 1
med_breakfast = 2
hi_breakfast = 3
energy_needed_no_breakfast = energy_needed_per_dine(no_breakfast,daily_energy_needs)
energy_needed_med_breakfast = energy_needed_per_dine(med_breakfast,daily_energy_needs)
energy_needed_hi_breakfast = energy_needed_per_dine(hi_breakfast,daily_energy_needs)
self.assertEqual(energy_needed_no_breakfast.get("Breakfast"),(daily_energy_needs*0.1))
self.assertEqual(energy_needed_no_breakfast.get("Morning_Snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_no_breakfast.get("Lunch"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_no_breakfast.get("Afternoon_Snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_no_breakfast.get("Dinner"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_no_breakfast.get("Breakfast"),energy_needed_med_breakfast.get("Breakfast"))
self.assertEqual(energy_needed_no_breakfast.get("Morning_Snack"),energy_needed_med_breakfast.get("Morning_Snack"))
self.assertEqual(energy_needed_no_breakfast.get("Lunch"),energy_needed_med_breakfast.get("Lunch"))
self.assertEqual(energy_needed_no_breakfast.get("Afternoon_Snack"),energy_needed_med_breakfast.get("Afternoon_Snack"))
self.assertEqual(energy_needed_no_breakfast.get("Dinner"),energy_needed_med_breakfast.get("Dinner"))
self.assertEqual(energy_needed_hi_breakfast.get("Breakfast"),(daily_energy_needs*0.1))
self.assertEqual(energy_needed_hi_breakfast.get("Morning_Snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_hi_breakfast.get("Lunch"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_hi_breakfast.get("Afternoon_Snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_hi_breakfast.get("Dinner"),(daily_energy_needs*0.3))
def test_physical_activity_recommendation(self):
level1_activity = 1
level2_activity = 2
......@@ -160,7 +132,37 @@ class FormulaTest(TestCase):
self.assertEqual(physical_activity_recommendation(level4_activity),PhysicalActivityResponse.LEVEL4_ACTIVITY)
self.assertEqual(physical_activity_recommendation(level5_activity),PhysicalActivityResponse.LEVEL5_ACTIVITY)
def test_energy_needed_per_dine(self):
daily_energy_needs = 450
never_breakfast = 1
light_breakfast = 2
heavy_breakfast = 3
energy_needed_no_breakfast = energy_needed_per_dine(never_breakfast,daily_energy_needs)
energy_needed_med_breakfast = energy_needed_per_dine(light_breakfast,daily_energy_needs)
energy_needed_hi_breakfast = energy_needed_per_dine(heavy_breakfast,daily_energy_needs)
energy_needed_error = energy_needed_per_dine(0,daily_energy_needs)
self.assertEqual(energy_needed_no_breakfast.get("breakfast"),(daily_energy_needs*0.1))
self.assertEqual(energy_needed_no_breakfast.get("morning_snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_no_breakfast.get("lunch"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_no_breakfast.get("afternoon_snack"),(daily_energy_needs*0.15))
self.assertEqual(energy_needed_no_breakfast.get("dinner"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_no_breakfast.get("breakfast"),energy_needed_med_breakfast.get("breakfast"))
self.assertEqual(energy_needed_no_breakfast.get("morning_snack"),energy_needed_med_breakfast.get("morning_snack"))
self.assertEqual(energy_needed_no_breakfast.get("lunch"),energy_needed_med_breakfast.get("lunch"))
self.assertEqual(energy_needed_no_breakfast.get("afternoon_snack"),energy_needed_med_breakfast.get("afternoon_snack"))
self.assertEqual(energy_needed_no_breakfast.get("dinner"),energy_needed_med_breakfast.get("dinner"))
self.assertEqual(energy_needed_hi_breakfast.get("breakfast"),(daily_energy_needs*0.2))
self.assertEqual(energy_needed_hi_breakfast.get("morning_snack"),(daily_energy_needs*0.1))
self.assertEqual(energy_needed_hi_breakfast.get("lunch"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_hi_breakfast.get("afternoon_snack"),(daily_energy_needs*0.1))
self.assertEqual(energy_needed_hi_breakfast.get("dinner"),(daily_energy_needs*0.3))
self.assertEqual(energy_needed_error,{})
def test_program_recommendation(self):
client_type_1 = program_recommendation(10,7,5) # Score 22-30
client_type_2 = program_recommendation(30,7,30) # Score 31-69
......@@ -172,32 +174,32 @@ class FormulaTest(TestCase):
client_type_8 = program_recommendation(30,115,30) # Score 160-179
client_type_9 = program_recommendation(200,115,30) # Score 180-345
self.assertEqual(client_type_1[0],ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_1[1],ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_1.get("priority_1"),ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_1.get("priority_2"),ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_2[0],ProgramRecommendationResponse.BABY_3)
self.assertEqual(client_type_2[1],ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_2.get("priority_1"),ProgramRecommendationResponse.BABY_3)
self.assertEqual(client_type_2.get("priority_2"),ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_3[0],ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_3[1],ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_3.get("priority_1"),ProgramRecommendationResponse.BABY_1)
self.assertEqual(client_type_3.get("priority_2"),ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_4[0],ProgramRecommendationResponse.GOALS_3)
self.assertEqual(client_type_4[1],ProgramRecommendationResponse.GOALS_1)
self.assertEqual(client_type_4.get("priority_1"),ProgramRecommendationResponse.GOALS_3)
self.assertEqual(client_type_4.get("priority_2"),ProgramRecommendationResponse.GOALS_1)
self.assertEqual(client_type_5[0],ProgramRecommendationResponse.GOALS_6)
self.assertEqual(client_type_5[1],ProgramRecommendationResponse.GOALS_3)
self.assertEqual(client_type_5.get("priority_1"),ProgramRecommendationResponse.GOALS_6)
self.assertEqual(client_type_5.get("priority_2"),ProgramRecommendationResponse.GOALS_3)
self.assertEqual(client_type_6[0],ProgramRecommendationResponse.BALANCED_1)
self.assertEqual(client_type_6[1],ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_6.get("priority_1"),ProgramRecommendationResponse.BALANCED_1)
self.assertEqual(client_type_6.get("priority_2"),ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_7[0],ProgramRecommendationResponse.BALANCED_3)
self.assertEqual(client_type_7[1],ProgramRecommendationResponse.BALANCED_1)
self.assertEqual(client_type_7.get("priority_1"),ProgramRecommendationResponse.BALANCED_3)
self.assertEqual(client_type_7.get("priority_2"),ProgramRecommendationResponse.BALANCED_1)
self.assertEqual(client_type_8[0],ProgramRecommendationResponse.BALANCED_6)
self.assertEqual(client_type_8[1],ProgramRecommendationResponse.BALANCED_3)
self.assertEqual(client_type_8.get("priority_1"),ProgramRecommendationResponse.BALANCED_6)
self.assertEqual(client_type_8.get("priority_2"),ProgramRecommendationResponse.BALANCED_3)
self.assertEqual(client_type_9[0],ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_9[1],None)
self.assertEqual(client_type_9.get("priority_1"),ProgramRecommendationResponse.TRIAL)
self.assertEqual(client_type_9.get("priority_2"),None)
......
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