-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…504) New files: * `api_getToBeCompletedProducts_test.dart`: Integration tests related to `ToBeCompletedQueryConfiguration` * `ToBeCompletedConfiguration.dart`: Query Configuration for all the to-be-completed products. Impacted file: * `api_saveProduct_test.dart`: unrelated failing test skip
- Loading branch information
1 parent
16e66af
commit b7c16ed
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:openfoodfacts/utils/AbstractQueryConfiguration.dart'; | ||
import 'package:openfoodfacts/utils/CountryHelper.dart'; | ||
|
||
/// Query Configuration for all the to-be-completed products. | ||
class ToBeCompletedQueryConfiguration extends AbstractQueryConfiguration { | ||
ToBeCompletedQueryConfiguration({ | ||
final OpenFoodFactsLanguage? language, | ||
final List<OpenFoodFactsLanguage> languages = | ||
const <OpenFoodFactsLanguage>[], | ||
final OpenFoodFactsCountry? country, | ||
final List<ProductField>? fields, | ||
final int? pageNumber, | ||
final int? pageSize, | ||
}) : super( | ||
language: language, | ||
languages: languages, | ||
country: country, | ||
fields: fields, | ||
additionalParameters: _convertToParametersList(pageNumber, pageSize), | ||
); | ||
|
||
static List<Parameter> _convertToParametersList( | ||
int? page, | ||
int? pageSize, | ||
) { | ||
final List<Parameter> result = <Parameter>[]; | ||
if (page != null) { | ||
result.add(PageNumber(page: page)); | ||
} | ||
if (pageSize != null) { | ||
result.add(PageSize(size: pageSize)); | ||
} | ||
return result; | ||
} | ||
|
||
@override | ||
String getUriPath() => '/state/to-be-completed.json'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:openfoodfacts/utils/OpenFoodAPIConfiguration.dart'; | ||
import 'package:openfoodfacts/utils/QueryType.dart'; | ||
import 'package:openfoodfacts/utils/ToBeCompletedConfiguration.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'test_constants.dart'; | ||
|
||
/// Integration tests related to [ToBeCompletedQueryConfiguration] | ||
void main() { | ||
OpenFoodAPIConfiguration.globalUser = TestConstants.PROD_USER; | ||
OpenFoodAPIConfiguration.globalQueryType = QueryType.PROD; | ||
|
||
group('$OpenFoodAPIClient get all to-be-completed products', () { | ||
test('all types', () async { | ||
final SearchResult result = await OpenFoodAPIClient.getProducts( | ||
OpenFoodAPIConfiguration.globalUser, | ||
ToBeCompletedQueryConfiguration(), | ||
queryType: OpenFoodAPIConfiguration.globalQueryType, | ||
); | ||
|
||
expect(result.page, 1); // default | ||
expect(result.products, isNotNull); | ||
expect(result.count, greaterThan(1000000)); // 20220630: was 2403413 | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters