-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
fix: Do not apply nutriscore prediction if it does not match the current nutriscore of the product #772
fix: Do not apply nutriscore prediction if it does not match the current nutriscore of the product #772
Changes from 1 commit
6680b9d
201911f
c570894
a37d23f
a0e2805
92e91ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from PIL import Image | ||
from robotoff.utils import get_image_from_url, get_logger, http_session | ||
|
||
image = get_image_from_url('https://world.openfoodfacts.org/images/products/802/509/314/0251/4.jpg', error_raise=False) | ||
|
||
|
||
def test_import_insights_from_image(mocker): | ||
barcode = "4640028621441" | ||
source_image = 'https://world.openfoodfacts.org/images/products/802/509/314/0251/4.jpg' | ||
ocr_url = 'https://world.openfoodfacts.org/images/products/802/509/314/0251/4.json' | ||
sever_domain = 'http://openfoodfacts.org/' | ||
|
||
expected_predictions_all = get_predictions_from_image(barcode, image, source_image, ocr_url, sever_domain) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's strange that you call it, to mock it ! You are a bit lost maybe because you don't know what to put inside it, but what you are testing should tell you what to put in it. I can also provides you some data from production. |
||
|
||
predictions_all_mock = mocker.patch( | ||
"robotoff.workers.tasks.import_image.import_insights_from_image.get_predictions_from_image", | ||
return_value=[expected_predictions_all], | ||
) | ||
|
||
imported_mock = import_insights(predictions_all, server_domain, automatic=True) | ||
|
||
|
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.
good idea, but you should put it in the repository instead (in a tests/data directory for example), we wont to avoid tests depending on an external service.
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.
An image with a nutriscore would be more cool ;-)
Like https://world.openfoodfacts.org/images/products/330/274/003/0949/front_fr.110.400.jpg
(There are plenty, see eg https://world.openfoodfacts.org/label/nutriscore-grade-c)