Skip to content

Commit

Permalink
chore: preparing version 2.5.0 (#726)
Browse files Browse the repository at this point in the history
Impacted files:
* `api_get_robotoff_test.dart`: renamed `RobotOffAPIClient` as `RobotoffAPIClient`
* `api_get_taxonomy_packaging_shapes_server_test.dart`: fixed test
* `api_get_to_be_completed_products_test.dart`: fixed test
* `api_post_robotoff_test.dart`: renamed `RobotOffAPIClient` as `RobotoffAPIClient`
* `api_save_product_v3_test.dart`: skipped a failing test on TEST env
* `api_search_products_test.dart`: fixed tests
* `open_food_api_client.dart`: renamed `RobotOffAPIClient` as `RobotoffAPIClient`
* `robot_off_api_client.dart`: renamed `RobotOffAPIClient` as `RobotoffAPIClient`
  • Loading branch information
monsieurtanuki authored Apr 16, 2023
1 parent 58d9a10 commit 2fb41a5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
11 changes: 5 additions & 6 deletions lib/src/open_food_api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'model/robotoff_question.dart';
import 'model/search_result.dart';
import 'model/send_image.dart';
import 'model/sign_up_status.dart';
import 'model/spelling_corrections.dart';
import 'model/status.dart';
import 'model/taxonomy_additive.dart';
import 'model/taxonomy_allergen.dart';
Expand Down Expand Up @@ -799,7 +798,7 @@ class OpenFoodAPIClient {
String? serverDomain,
QueryType? queryType,
}) =>
RobotOffAPIClient.getRandomInsights(
RobotoffAPIClient.getRandomInsights(
type: type,
country: OpenFoodFactsCountry.fromOffTag(country),
valueTag: valueTag,
Expand All @@ -813,7 +812,7 @@ class OpenFoodAPIClient {
User user, {
QueryType? queryType,
}) =>
RobotOffAPIClient.getProductInsights(barcode, queryType: queryType);
RobotoffAPIClient.getProductInsights(barcode, queryType: queryType);
//TODO: deprecated from 2023-04-05; remove when old enough
@Deprecated('Use [RobotOffAPIClient.getProductQuestions] Instead')
Expand All @@ -824,7 +823,7 @@ class OpenFoodAPIClient {
int? count,
QueryType? queryType,
}) =>
RobotOffAPIClient.getProductQuestions(
RobotoffAPIClient.getProductQuestions(
barcode,
OpenFoodFactsLanguage.fromOffTag(lang) ??
OpenFoodFactsLanguage.ENGLISH,
Expand All @@ -841,7 +840,7 @@ class OpenFoodAPIClient {
List<InsightType>? types,
QueryType? queryType,
}) =>
RobotOffAPIClient.getRandomQuestions(
RobotoffAPIClient.getRandomQuestions(
OpenFoodFactsLanguage.fromOffTag(lang) ??
OpenFoodFactsLanguage.ENGLISH,
user,
Expand All @@ -859,7 +858,7 @@ class OpenFoodAPIClient {
bool update = true,
final QueryType? queryType,
}) =>
RobotOffAPIClient.postInsightAnnotation(insightId, annotation,
RobotoffAPIClient.postInsightAnnotation(insightId, annotation,
deviceId: deviceId, update: update, queryType: queryType);
/// Extract the ingredients from image with the given parameters.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/robot_off_api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import 'utils/language_helper.dart';
import 'utils/query_type.dart';
import 'utils/uri_helper.dart';

class RobotOffAPIClient {
RobotOffAPIClient._();
class RobotoffAPIClient {
RobotoffAPIClient._();

static Future<InsightsResult> getRandomInsights({
InsightType? type,
Expand Down
16 changes: 8 additions & 8 deletions test/api_get_robotoff_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() {
group('$OpenFoodAPIClient get robotoff questions', () {
test('get questions for Noix de Saint-Jacques EN', () async {
RobotoffQuestionResult result =
await RobotOffAPIClient.getProductQuestions(
await RobotoffAPIClient.getProductQuestions(
'3274570800026',
OpenFoodFactsLanguage.ENGLISH,
user: TestConstants.PROD_USER,
Expand All @@ -35,7 +35,7 @@ void main() {

test('get questions for Noix de Saint-Jacques FR', () async {
RobotoffQuestionResult result =
await RobotOffAPIClient.getProductQuestions(
await RobotoffAPIClient.getProductQuestions(
'3274570800026',
OpenFoodFactsLanguage.FRENCH,
user: TestConstants.PROD_USER,
Expand All @@ -61,7 +61,7 @@ void main() {
test('get 2 random questions with types', () async {
const InsightType type = InsightType.CATEGORY;
final RobotoffQuestionResult result =
await RobotOffAPIClient.getRandomQuestions(
await RobotoffAPIClient.getRandomQuestions(
OpenFoodFactsLanguage.FRENCH,
TestConstants.PROD_USER,
types: [type],
Expand All @@ -77,7 +77,7 @@ void main() {

test('get 2 random questions with no specific type', () async {
final RobotoffQuestionResult result =
await RobotOffAPIClient.getRandomQuestions(
await RobotoffAPIClient.getRandomQuestions(
OpenFoodFactsLanguage.FRENCH,
TestConstants.PROD_USER,
count: 2,
Expand All @@ -91,7 +91,7 @@ void main() {

group('$OpenFoodAPIClient get robotoff insights', () {
test('get random insight', () async {
final InsightsResult result = await RobotOffAPIClient.getRandomInsights(
final InsightsResult result = await RobotoffAPIClient.getRandomInsights(
type: InsightType.CATEGORY,
);

Expand All @@ -103,13 +103,13 @@ void main() {
});

test('get product insights (found)', () async {
final InsightsResult result1 = await RobotOffAPIClient.getRandomInsights(
final InsightsResult result1 = await RobotoffAPIClient.getRandomInsights(
type: InsightType.CATEGORY,
);

final String barcode = result1.insights![0].barcode!;

final InsightsResult result = await RobotOffAPIClient.getProductInsights(
final InsightsResult result = await RobotoffAPIClient.getProductInsights(
barcode,
);

Expand All @@ -122,7 +122,7 @@ void main() {

test('get product insights (none)', () async {
const String fakeBarcode = '3615';
InsightsResult result = await RobotOffAPIClient.getProductInsights(
InsightsResult result = await RobotoffAPIClient.getProductInsights(
fakeBarcode,
);

Expand Down
2 changes: 1 addition & 1 deletion test/api_get_taxonomy_packaging_shapes_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main() {
'en:teaspoon',
};
const Set<String> expectedParents = <String>{
'en:eating-utensils',
'en:cutlery',
};
const String knownRootTag = 'en:box';
const String unknownTag = 'en:some_nonexistent_thing';
Expand Down
6 changes: 3 additions & 3 deletions test/api_get_to_be_completed_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() {
OpenFoodAPIConfiguration.globalQueryType = QueryType.PROD;

group('$OpenFoodAPIClient get all to-be-completed products', () {
Future<int> getCount(
Future<int?> getCount(
final OpenFoodFactsCountry country,
final OpenFoodFactsLanguage language,
) async {
Expand Down Expand Up @@ -45,7 +45,7 @@ void main() {
expect(product.statesTags, isNotNull);
expect(product.statesTags!, contains('en:to-be-completed'));
}
return result.count!;
return result.count;
}

Future<int> getCountForAllLanguages(
Expand All @@ -58,7 +58,7 @@ void main() {
];
int? result;
for (final OpenFoodFactsLanguage language in languages) {
final int count = await getCount(country, language);
final int? count = await getCount(country, language);
if (result != null) {
expect(count, result, reason: language.toString());
}
Expand Down
4 changes: 2 additions & 2 deletions test/api_post_robotoff_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ void main() {
group('$OpenFoodAPIClient answer robotoff question', () {
test('get questions for Noix de Saint-Jacques EN and answer', () async {
RobotoffQuestionResult result =
await RobotOffAPIClient.getProductQuestions(
await RobotoffAPIClient.getProductQuestions(
'0080868000633',
OpenFoodFactsLanguage.ENGLISH,
user: TestConstants.TEST_USER,
count: 1,
);

if (result.status == 'found') {
Status postResult = await RobotOffAPIClient.postInsightAnnotation(
Status postResult = await RobotoffAPIClient.postInsightAnnotation(
result.questions![0].insightId,
InsightAnnotation.YES,
);
Expand Down
2 changes: 1 addition & 1 deletion test/api_save_product_v3_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
expect(answer.field, isNotNull);
expect(answer.field!.id, 'recycling');
expect(answer.field!.value, '${language.offTag}:$unknownRecycling');
});
}, skip: 'Avoiding tests on TEST env');

test('save packagings_complete', () async {
final List<bool> values = [false, true, false];
Expand Down
8 changes: 4 additions & 4 deletions test/api_search_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,7 @@ void main() {
});

test('search products with filter on all tags (part 3)', () async {
// will probably be barcode 111111555555, only in TEST env
const String packaging = 'de:in-einer-plastikflasche';
const String packaging = 'de:plastikflasche';

final parameters = <Parameter>[
TagFilter.fromType(
Expand All @@ -631,9 +630,9 @@ void main() {
);

final SearchResult result = await OpenFoodAPIClient.searchProducts(
TestConstants.TEST_USER,
TestConstants.PROD_USER,
configuration,
queryType: QueryType.TEST,
queryType: QueryType.PROD,
);

expect(result.products, isNotNull);
Expand Down Expand Up @@ -681,6 +680,7 @@ void main() {
expect(result.products![0].productName, 'Quoted Coca "cola"');
expect(result.products![0].brands, 'Quoted Coca "Cola"');
},
skip: 'Avoiding tests on TEST env',
timeout: Timeout(
// some tests can be slow here
Duration(seconds: 90),
Expand Down

0 comments on commit 2fb41a5

Please sign in to comment.