Skip to content

Commit

Permalink
Add section for pytest-recording plugin in CONTRIBUTING.md
Browse files Browse the repository at this point in the history
* **Plugin usage**: Add a section explaining the use of `pytest-recording` plugin for creating VCR cassettes.
* **Recording instructions**: Provide instructions on how to record a new VCR cassette using `uv run pytest --record-mode=once tests/desired_test_module.py`.
* **Configuration links**: Link to the configuration in `tests/conftest.py` and the cassettes in `tests/cassettes`.
* **Header removals**: Document header removals from responses to exclude sensitive information.
* **Size comment**: Add a comment about keeping the cassettes less than 1 MB in size.
  • Loading branch information
jamesbraza committed Sep 16, 2024
1 parent 846f136 commit 9d49b84
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ Use the following commands:

See our GitHub Actions [`tests.yml`](.github/workflows/tests.yml) for further reference.

## Using `pytest-recording` and VCR cassettes

We use the [`pytest-recording`](https://github.com/kiwicom/pytest-recording) plugin
to create VCR cassettes to cache HTTP requests,
making our unit tests more deterministic.

To record a new VCR cassette:

```bash
uv run pytest --record-mode=once tests/desired_test_module.py
```

And the new cassette(s) should appear in [`tests/cassettes`](tests/cassettes).

Our configuration for `pytest-recording` can be found in [`tests/conftest.py`](tests/conftest.py).
This includes header removals (e.g. OpenAI `authorization` key)
from responses to ensure sensitive information is excluded from the cassettes.

Please ensure cassettes are less than 1 MB
to keep tests loading quickly.

## Additional resources

For more information on contributing, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file in the repository.
Expand Down

0 comments on commit 9d49b84

Please sign in to comment.