July 2017
Beginner to intermediate
340 pages
7h 43m
English
If you are using Requests to perform all the calls--or you are using a library that is based on Requests and that does not customize it too much, this isolation work is easier to do, thanks to the transport adapters we saw earlier in this chapter.
The requests-mock project (https://requests-mock.readthedocs.io) implements an adapter that will let you mock network calls in your tests.
Earlier in this chapter, we saw an example of a Flask app that was an HTTP endpoint to serve some content on its /api endpoint.
That application used a Request session that was created by a setup_connector() function and retrieved in a view by a get_connector() function.
In the following test, we're mounting the ;requests_mock adapter ...
Read now
Unlock full access