From 9d49b840cfc05abd9f23d6aad3a9a19426e874bf Mon Sep 17 00:00:00 2001 From: James Braza Date: Mon, 16 Sep 2024 11:23:42 -0700 Subject: [PATCH] Add section for `pytest-recording` plugin in `CONTRIBUTING.md` * **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. --- CONTRIBUTING.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85c9a134..55c75362 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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.