Skip to content

Commit

Permalink
Add documentation of new hooks to "Configuring" page
Browse files Browse the repository at this point in the history
  • Loading branch information
jarhill0 committed Jan 12, 2020
1 parent 1f68d10 commit 1355929
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/source/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,27 @@ have our hook, we need merely register it like so:
And we no longer need to worry about leaking sensitive data.

In addition to the ``before_record`` and ``before_playback`` hooks,
version 0.9.0 of Betamax adds :meth:`.after_start` and :meth:`.before_stop`
hooks. These two hooks both will pass the current
:class:`~betamax.cassette.cassette.Cassette` to the callback function provided.
Register these hooks like so:

.. code-block:: python
def hook(cassette):
if cassette.is_recording():
print("This cassette is recording!")
# Either
config.after_start(callback=hook)
# Or
config.before_stop(callback=hook)
These hooks are useful for performing configuration actions external to Betamax
at the time Betamax is invoked, such as setting up correct authentication to
an API so that the recording will not encounter any errors.


Setting default serializer
``````````````````````````
Expand Down

0 comments on commit 1355929

Please sign in to comment.