Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Backend
Commits
021d3ed0
Commit
021d3ed0
authored
Apr 26, 2021
by
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dietela_quiz/formulas.py
View file @
021d3ed0
...
...
@@ -304,10 +304,10 @@ 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
>
1
2
):
if
(
total_sugar_salt_fat_score
<
0
)
or
(
total_sugar_salt_fat_score
>
1
6
):
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
.
EXCESSIVE
...
...
dietela_quiz/tests.py
View file @
021d3ed0
...
...
@@ -688,8 +688,8 @@ class FormulaTest(TestCase):
def
test_get_total_sugar_salt_fat_score_with_valid_choice
(
self
):
fried_food_choice
=
1
sweet_snacks_choice
=
3
sweet_drinks_choice
=
1
packaged_food_choice
=
2
sweet_drinks_choice
=
5
packaged_food_choice
=
5
self
.
assertEqual
(
get_total_sugar_salt_fat_score
(
...
...
@@ -697,7 +697,7 @@ class FormulaTest(TestCase):
sweet_snacks_choice
,
sweet_drinks_choice
,
packaged_food_choice
),
3
)
10
)
def
test_get_total_sugar_salt_fat_score_with_invalid_fried_food_choice
(
self
):
...
...
@@ -758,14 +758,14 @@ class FormulaTest(TestCase):
def
test_get_sugar_salt_fat_problem_response_with_invalid_total_score
(
self
):
with
self
.
assertRaises
(
ValueError
):
total_sugar_salt_fat_score
=
1
3
total_sugar_salt_fat_score
=
1
7
get_sugar_salt_fat_problem_response
(
total_sugar_salt_fat_score
)
def
test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_1
(
self
):
total_sugar_salt_fat_score
=
4
total_sugar_salt_fat_score
=
6
self
.
assertEqual
(
get_sugar_salt_fat_problem_response
(
total_sugar_salt_fat_score
),
...
...
@@ -773,7 +773,7 @@ class FormulaTest(TestCase):
def
test_get_sugar_salt_fat_problem_response_with_valid_total_score_condition_2
(
self
):
total_sugar_salt_fat_score
=
7
total_sugar_salt_fat_score
=
10
self
.
assertEqual
(
get_sugar_salt_fat_problem_response
(
total_sugar_salt_fat_score
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment