-
-
Notifications
You must be signed in to change notification settings - Fork 314
#232: Make all endpoints async #256
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
Conversation
These are required to be able to test asyncio functionality, as well as making ASGI test clients play nice asynchronously.
- Move test fixtures into tests/fixtures.py - Update test fixtures to mock aiohttp.ClientSession.get, instead of requests.get - Add a context manager to replace the global httputils.client_session with an AsyncMock - Misc. cleanup
I didn't see this file when I first added the new fixtures.
One can still define a separate responder function here, but since this is the only response defined for the tests thus far, this seems like a reasonable default.
|
Builds are currently failing for 3.6 and 3.7, I wrote this PR under 3.8 - looks like some of the async test fixtures are new in the standard lib as of 3.7 and 3.8. I'll take a look for backport options for these. |
07e4074 to
99ea07e
Compare
Using these as decorators causes a lot of problems when combined with Pytest fixtures, often resulting in the mock not applying.
Kilo59
left a comment
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.
Great work!
| [dev-packages] | ||
| async-asgi-testclient = "*" | ||
| async_generator = "*" | ||
| asyncmock = "*" |
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.
These back-ports should be adjusted so that they are only installed when required.
https://pipenv.readthedocs.io/en/latest/basics/#specifying-versions-of-a-package
https://pipenv.readthedocs.io/en/latest/advanced/#specifying-basically-anything
I'll try to do this tonight if I have a chance.
Thanks for all the notes, should make this easy.
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.
No problem, happy to help!
|
@all-contributors please add @james-gray for code |
|
I've put up a pull request to add @james-gray! 🎉 |
This branch adds async support to all API endpoints to make them non-blocking, using
asyncioandaiohttp.aiohttpto make the two requests for data sources instead of requests, as requests is not compatible withasyncioA key piece of this is the addition of a globalaiohttp.ClientSessioninstance, which exists for the entire application run.ClientSession.Added dependencies:
#232
(Reopening this on my personal GH account to avoid authorship confusion.)