test(registrations): fix flaky test #1023
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
test_price_group_list_ordering
failed in certain circumstances, e.g.pytest -k order
. This PR fixes that issue.PriceGroupViewSet orders the price groups by
description
,description
is a translated field, andPriceGroupFactory
overrides all languages with"<lang> Price Group <seq>"
, where<lang>
is the language code and the<seq>
is a growing sequence of numbers. In certain circumstances, this causes the order to become something unexpected, e.g. with the descriptionsEN Price Group 9
andEN Price Group 10
, the latter price groups would be placed first (because"10"
>"9"
).Solved the issue by setting the translation directly and making sure that the correct translation is used.
Also refactored the test a bit. I'm not sure if I agree with the test using paging since we're testing whether the order of the price groups is correct or not and it adds unnecessary complexity, but decided to keep it as it is.
Refs: LINK-2210