-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add responses library for mocking requests * Mock Zotero API and bibtex entries Instead of setting up a testing environment in Zotero, I have mocked the API documented in [Zotero API docs](https://www.zotero.org/support/dev/web_api/v3/basics) especially with the pagination feature that splits the bibtex into chunks with a maximum length that they call 'limit'. In the fixture, the limit is set to 25 or the default. Along with the mock API, I needed a function that can generate n bibtex entries to test paginated and non-paginated results. * Add test loading bibtex from Zotero To test paginated and non-paginated responses, this test parametrizes the mock_zotero_api fixture with API endpoints with 4 and 150 results respectively. * Add function to handle Zotero API requests Zotero API's "Sorting and Pagination" [docs](https://www.zotero.org/support/dev/web_api/v3/basics) explain that results are limited to an integer number of results that can increase to a maximum of 100 results per request. If there are more results that match the search criteria, a "Link" header will be added with a `rel=next` link. The `tempfile_from_zotero` function leverages the response header and continues requesting the `next` url until all results are returned. To prevent runaway conditions, an arbitrary hard limit of 999 has been placed. * Sanitize Zotero API URL before request To prevent the user from adding problematic query params to the Zotero URL, the `sanitize_zotero_query()` function ensures that the requested format is bibtex and the limit is set to the maximum permitted by Zotero to reduce the total number of requests. The mocked Zotero API needs to represent these latest changes too. * Add responses to GHA testing deps
- Loading branch information
Showing
5 changed files
with
156 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
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
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
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
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