Fakultas Ilmu Komputer UI

Commit 021d3ed0 authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto
Browse files

[HOTFIX] Fix GGL formula bugs in dietela quiz

parent b5c260dc
Pipeline #73005 passed with stage
in 5 minutes and 58 seconds
...@@ -304,10 +304,10 @@ def get_total_sugar_salt_fat_score( ...@@ -304,10 +304,10 @@ def get_total_sugar_salt_fat_score(
def get_sugar_salt_fat_problem_response(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 > 12): if (total_sugar_salt_fat_score < 0) or (total_sugar_salt_fat_score > 16):
raise ValueError("Invalid total sugar, salt, fat score!") raise ValueError("Invalid total sugar, salt, fat score!")
if 0 <= total_sugar_salt_fat_score <= 5: if 0 <= total_sugar_salt_fat_score <= 7:
return SugarSaltFatProblemResponse.CONTROLLED return SugarSaltFatProblemResponse.CONTROLLED
return SugarSaltFatProblemResponse.EXCESSIVE return SugarSaltFatProblemResponse.EXCESSIVE
......
...@@ -688,8 +688,8 @@ class FormulaTest(TestCase): ...@@ -688,8 +688,8 @@ class FormulaTest(TestCase):
def test_get_total_sugar_salt_fat_score_with_valid_choice(self): def test_get_total_sugar_salt_fat_score_with_valid_choice(self):
fried_food_choice = 1 fried_food_choice = 1
sweet_snacks_choice = 3 sweet_snacks_choice = 3
sweet_drinks_choice = 1 sweet_drinks_choice = 5
packaged_food_choice = 2 packaged_food_choice = 5
self.assertEqual( self.assertEqual(
get_total_sugar_salt_fat_score( get_total_sugar_salt_fat_score(
...@@ -697,7 +697,7 @@ class FormulaTest(TestCase): ...@@ -697,7 +697,7 @@ class FormulaTest(TestCase):
sweet_snacks_choice, sweet_snacks_choice,
sweet_drinks_choice, sweet_drinks_choice,
packaged_food_choice), packaged_food_choice),
3) 10)
def test_get_total_sugar_salt_fat_score_with_invalid_fried_food_choice( def test_get_total_sugar_salt_fat_score_with_invalid_fried_food_choice(
self): self):
...@@ -758,14 +758,14 @@ class FormulaTest(TestCase): ...@@ -758,14 +758,14 @@ class FormulaTest(TestCase):
def test_get_sugar_salt_fat_problem_response_with_invalid_total_score( def test_get_sugar_salt_fat_problem_response_with_invalid_total_score(
self): self):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
total_sugar_salt_fat_score = 13 total_sugar_salt_fat_score = 17
get_sugar_salt_fat_problem_response( get_sugar_salt_fat_problem_response(
total_sugar_salt_fat_score) total_sugar_salt_fat_score)
def test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_1( def test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_1(
self): self):
total_sugar_salt_fat_score = 4 total_sugar_salt_fat_score = 6
self.assertEqual( self.assertEqual(
get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score), get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score),
...@@ -773,7 +773,7 @@ class FormulaTest(TestCase): ...@@ -773,7 +773,7 @@ class FormulaTest(TestCase):
def test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_2( def test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_2(
self): self):
total_sugar_salt_fat_score = 7 total_sugar_salt_fat_score = 10
self.assertEqual( self.assertEqual(
get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score), get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score),
......
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