openfoodfacts-dart
openfoodfacts-dart copied to clipboard
Fix get robotoff questions tests
The get robotoff questions
, get robotoff insights
and get robotoff ingredient spelling corrections
tests in api_getRobotoff_test.dart
are currently all skipped because we specified them to do so (skip: 'This Group of tests is unstable'),
We should fix them.
Edit:
The same applies for answer robotoff question
in api_postRobotoff_test.dart
Error when the skip parameter is removed:
package:openfoodfacts/model/RobotoffQuestion.dart 50:17 RobotoffQuestion.fromJson
package:openfoodfacts/model/RobotoffQuestion.g.dart 13:35 _$RobotoffQuestionResultFromJson
package:openfoodfacts/model/RobotoffQuestion.dart 20:7 new RobotoffQuestionResult.fromJson
package:openfoodfacts/openfoodfacts.dart 400:41 OpenFoodAPIClient.getRobotoffQuestionsForProduct
===== asynchronous gap ===========================
test\api_getRobotoff_test.dart 18:11 main.<fn>.<fn>
type 'List<dynamic>' is not a subtype of type 'Iterable<Map<String, dynamic>>' in type cast
package:openfoodfacts/model/RobotoffQuestion.dart 50:17 RobotoffQuestion.fromJson
package:openfoodfacts/model/RobotoffQuestion.g.dart 13:35 _$RobotoffQuestionResultFromJson
package:openfoodfacts/model/RobotoffQuestion.dart 20:7 new RobotoffQuestionResult.fromJson
package:openfoodfacts/openfoodfacts.dart 400:41 OpenFoodAPIClient.getRobotoffQuestionsForProduct
===== asynchronous gap ===========================
test\api_getRobotoff_test.dart 43:11 main.<fn>.<fn>
type 'List<dynamic>' is not a subtype of type 'Iterable<Map<String, dynamic>>' in type cast
package:openfoodfacts/model/RobotoffQuestion.dart 50:17 RobotoffQuestion.fromJson
package:openfoodfacts/model/RobotoffQuestion.g.dart 13:35 _$RobotoffQuestionResultFromJson
package:openfoodfacts/model/RobotoffQuestion.dart 20:7 new RobotoffQuestionResult.fromJson
package:openfoodfacts/openfoodfacts.dart 442:41 OpenFoodAPIClient.getRandomRobotoffQuestion
===== asynchronous gap ===========================
test\api_getRobotoff_test.dart 68:11 main.<fn>.<fn>
type 'List<dynamic>' is not a subtype of type 'Iterable<Map<String, dynamic>>' in type cast
package:openfoodfacts/model/Insight.dart 92:17 Insight.fromJson
package:openfoodfacts/model/Insight.g.dart 12:25 _$InsightsResultFromJson
package:openfoodfacts/model/Insight.dart 65:7 new InsightsResult.fromJson
package:openfoodfacts/openfoodfacts.dart 346:24 OpenFoodAPIClient.getRandomInsight
===== asynchronous gap ===========================
test\api_getRobotoff_test.dart 87:33 main.<fn>.<fn>
type 'List<dynamic>' is not a subtype of type 'Iterable<Map<String, dynamic>>' in type cast
package:openfoodfacts/model/Insight.g.dart 12:51 _$InsightsResultFromJson
package:openfoodfacts/model/Insight.dart 65:7 new InsightsResult.fromJson
package:openfoodfacts/openfoodfacts.dart 368:27 OpenFoodAPIClient.getProductInsights
===== asynchronous gap ===========================
test\api_getRobotoff_test.dart 104:33 main.<fn>.<fn>
type 'Null' is not a subtype of type 'List<dynamic>' in type cast
test\api_getRobotoff_test.dart 130:44 main.<fn>.<fn>
test\api_getRobotoff_test.dart 125:54 main.<fn>.<fn>
type 'Future<SpellingCorrection?>' is not a subtype of type 'FutureOr<SpellingCorrection>' in type cast
With #274 most robotoff queries work. Still, the spelling part doesn't work, and I assume something is missing anyway.
The current test is about the suggested correct spelling(s) of 'fqrine de blé'
, which obviously would be 'farine de blé'
(at least in french).
Unfortunately the output is 'fqrine de blé'
(which is also the input): https://robotoff.openfoodfacts.net/api/v1/predict/ingredients/spellcheck?text=fqrine+de+bl%C3%A9
Anyway, there's no language parameter: how could the spellcheck discriminate among 'farinha'
, 'harina'
, 'farina'
and 'farine
' from for instance 'farini
in input?
Another strange thing is that the generated json does not seem encoded in utf8.
While the product json is, or at least Süßungsmittel
is displayed correctly in https://world.openfoodfacts.net/api/v0/product/1111111111111.json?lc=de
@stephanegigandet @teolemon Are there additional parameters needed in api/v1/predict/ingredients/spellcheck
in order to get relevant results (like adding the language) or to force UTF8 output?
Is Robotff spellcheck used somewhere in smooth-app?
@raphael0202 Actually we don't use it in smooth-app.
ok so you can drop the tests (and the code) completely, next revamp of the spellcheck code will probably require some API change as well.