Getting ready

We'll look at mocking a stateful RESTful web services request. In this case, we'll be using a database API for the Elastic database. See https://www.elastic.co/ for more information on this database. The database has the advantage of working with simple RESTful web services. These can easily be mocked to simple, fast unit tests.

For this recipe, we'll test a function that uses the RESTful API to create records. Representational State Transfer (REST) is a technique for using  Hypertext Transfer Protocol (HTTP) to transfer a representation of an object's state between processes. To create a database record, for example, a client will transfer a representation of an object's state to the database server, using HTTP POST requests. ...

Get Modern Python Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.