We are aware of how testing works, but now let's say we have a third-party application/service integrated via API calls with our application. It would not be a great idea to make calls to this application/service every time tests are run. Sometimes, these can be paid, too, and making calls during tests cannot only be expensive, but also affect the statistics of that service. Mocking plays a very important role in such scenarios. The simplest example of this can be mocking SMTP for emails. In this recipe, we will integrate our application with the geoip library and then test it via mocking.
Using mocking to avoid real API access
Getting ready
In Python 3, mock has been included as a standard package in the unittest library...