-
-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: updated test for serving_size for nutrition table #8685
Conversation
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @benbenben2
check_quality_and_test_product_has_quality_tag( | ||
$product_ref, | ||
'en:nutrition-data-per-serving-missing-serving-size', | ||
'serving size should be provided if "per serving" is selected', 0 | ||
); | ||
check_quality_and_test_product_has_quality_tag( | ||
$product_ref, | ||
'en:nutrition-data-per-serving-serving-quantity-is-0', | ||
'serving size equal to 0 is unexpected', 0 | ||
); | ||
check_quality_and_test_product_has_quality_tag( | ||
$product_ref, | ||
'en:nutrition-data-per-serving-serving-quantity-is-not-recognized', | ||
'serving size cannot be parsed', 1 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I see we reapeat the test 3 times, shan't we change check_quality_and_test_product_has_quality_tag to have a list of tags to check for presence, and a list of tags to check for absence ?
Of course in another PR.
Very good! Thanks a lot @benbenben2 this is far more clear and useful as before. |
Reminder: serving_size is the input from the contributor, serving_quantity is the extracted quantity from the serving_size
Nutrition data per serving - Serving quantity is unknown
Nutrition data per serving - Serving quantity is not recognized
Nutrition data per serving - Serving quantity is 0 --> only when we actually get "0 g" or similar
would be exact same as: en:nutrition-data-per-serving-missing-serving-size
previously it was a warning
updated to be an error
Remark about 2 & 3)
Reason is that normalize_serving_size subroutine in Units.pm returns 0 if it cannot extract the serving otherwise it returns the result of the subroutine unit_to_g, and this latter return either something or nothing (i.e., not 0)
(new) en:nutrition-data-per-serving-serving-quantity-is-not-recognized
This covers both cases:
2)a) Serving quantity is not recognized - but regex did work) and
2)b) Serving quantity is not recognized - and regex to extract "quantity" and "unit" does not work
This should never be 0
en:nutrition-data-per-serving-serving-quantity-is-0
For "0 g" or "0 mL"
(from feat: add data quality warning for serving size without digit #8057) en:Nutrition data per serving - Serving size is missing digits
tested locally:
input - result
10 ml - ok
empty - 1
serving - 2 and 4
0g - 3
0 mL - 3