-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add language filter to sync-ingredients management command. #1875
base: master
Are you sure you want to change the base?
Conversation
…anguage code if desired.
mock_request.assert_called_with( | ||
'https://wger.de/api/v2/ingredient/?limit=999', | ||
'https://wger.de/api/v2/ingredient/?limit=999&language=2', |
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.
I'd add a new simple test here, something like def test_ingredient_sync_languages
that only checks that the correct URL is called
url = make_uri( | ||
INGREDIENTS_ENDPOINT, | ||
server_url=remote_url, | ||
query={'limit': API_MAX_ITEMS, 'language': language_id}, |
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.
I'd just allow passing all languages at once, seems easier that way. For this we just need to add 'in' to IngredientFilterSet
, like in 'id'. Then we can do query={'limit': API_MAX_ITEMS, 'language__in': ','.join([languages])}
(this also works if we only pass one)
Proposed Changes
python manage.py sync-ingredients --languages=en,fr,es
Please check that the PR fulfills these requirements
wger.nutrition.tests.test_xync.TestSyncMethods
has been slightly modified to ensure uri was called with proper filter.Other questions
(e.g. database migration)? No