Skip to main content

Test from HTTP interactions to dataframe processed.

Project description

.. image::
.. image::
:alt: Documentation Status
.. image::
.. image::
:alt: Pypi package


Combine `vcrpy <>`_ with
`pandas <>`_ to not only mock your HTTP interactions,
but also tests your post-processing work to get a pandas DataFrame.


.. code:: python


def test_meteo_get_wind_speed(vcrpandas, client):
start = pd.Timestamp('2018-01-01', tz='CET')
end = pd.Timestamp('2018-02-01', tz='CET')
with vcrpandas("meteo_get_wind_speed") as recorder:
df = client.get_wind_speed(start, end)

.. code:: bash

# call pytest for the first time to generate samples
> pytest --vcr-record="new_episodes"

# you can now replay it:
> pytest

Behind the hood, 2 files are generated by the first run:

- a *meteo_get_wind_speed.yaml*, which is the reponse obtained by
the first HTTP interaction.
- a *meteo_get_wind_speed.pickle* that serve to compare the formatting from
the mocked response to the pandas DataFrame, types included.


.. code:: bash

pip install pytest-vcrpandas

Advanced Usage

To configure VCR, here is how to procee:

.. code:: python

def my_vcrpandas(vcrpandas):
custom_vcr_config = dict(
match_on=['uri', 'method'],
filter_headers=['authorization'], # filter information from HTTP Headers
filter_query_parameters=['api_key'], # filter information from HTTP query string
filter_post_data_parameters=['client_secret'], # filter information from HTTP post data
return vcrpandas

def test_mysupertest(my_vcrpandas):
with my_vcrpandas("random_bucket_name") as recorder:

Refere to `VCR configuration <`_ and
`VCR Advanced Features <>`_ to get the
full list of options.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-vcrpandas-0.0.2.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

pytest_vcrpandas-0.0.2-py2.py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page