basicΒΆ

This is by far the simplest example on how to get started with HoverPy.

from hoverpy import capture, simulate
import requests

@capture("requests.db")
def captured_get():
    print(requests.get("http://time.jsontest.com").json())

@simulate("requests.db")
def simulated_get():
    print(requests.get("http://time.jsontest.com").json())

captured_get()
simulated_get()

$ python examples/basic/basic.py

You should see time printed twice. Notice the time is the same on each request, that is because the simulated_get was served from data that was captured while calling captured_get.

You may have noticed this created a requests.db inside your current directory. This is a boltdb database, holding our requests, and their responses.