-
Notifications
You must be signed in to change notification settings - Fork 50
Add unit tests for _paginate_with_dead_link_mask #891
Conversation
API Developer Docs Preview: Ready https://wordpress.github.io/openverse-api/_preview/891 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
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.
Thank you for providing such comprehensive documentation for this test! I could not think of any edge cases to add.
def _unmasked_query_end(page_size, page): | ||
""" | ||
Used to retrieve the upper index of results to retrieve | ||
from Elasticsearch under the following conditions: | ||
1. There is no query mask | ||
2. The lower index is beyond the scope of the existing query mask | ||
3. The lower index is within the scope of the existing query mask | ||
but the upper index exceeds it | ||
|
||
In all these cases, the query mask is not used to calculate the upper index. | ||
""" | ||
return ceil(page_size * page / (1 - DEAD_LINK_RATIO)) | ||
|
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.
❤️
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.
Excellent documentation, lgtm.
Co-authored-by: Zack Krida <[email protected]>
Co-authored-by: Olga Bulat <[email protected]>
Fixes
Fixes #871 by @AetherUnbound
Description
Wow, what a monster of a function. There are a lot of branches, each with their own possible edge cases. The third branch is by far the most complex and writing cases for it is likewise complex. I've had a hard time wrapping my head around possible edge cases, particularly because the third branch handles the edge cases so well, so each sub-branch is already exercising one possible edge case anyway. I think they're all sufficiently covered, but let me know if you notice any holes.
Testing Instructions
Read the tests. They should pass CI and should make sense. Review the additional documentation I've added.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin