keboola.vcr
VCR recording, sanitization, and validation for Keboola component HTTP interactions.
Installation
pip install keboola.vcr
Usage
from keboola.vcr.recorder import VCRRecorder
from keboola.vcr.sanitizers import DefaultSanitizer
recorder = VCRRecorder(
cassette_dir="tests/cassettes/my_test",
secrets={"api_key": "secret"},
)
Features
- Recording: Captures real HTTP interactions via vcrpy and stores them as JSON cassettes
- Sanitization: Redacts secrets, tokens, and sensitive fields before saving cassettes
- Scaffolding: Generates test directory structures from component config definitions
- Validation: Compares output snapshots to detect regressions
Sanitizing data before the component reads it
By default, sanitizers scrub the cassette only — during recording the
component still receives the real API response, so real values can end up in the
component's output tables. To stop real customer data from ever reaching the
component, tag a sanitizer with scrub_before_read=True. The recorder then
redacts those fields in the response before the component reads them, so the
output is clean regardless of format (CSV, Parquet, or direct-to-Storage).
# tests/.../sanitizers.py
from keboola.vcr import BodyFieldSanitizer
def get_sanitizers(config):
return [
# PII the component only reads and emits → redacted before the component reads it
BodyFieldSanitizer(fields=["customer_name", "email", "phone"], scrub_before_read=True),
]
Rule: only tag fields the component consumes and emits. Never tag a value the component sends back to the live API during recording — a pagination cursor, an async job ID, or an OAuth token — because it must stay real for the follow-up request to succeed. Token/secret sanitizers stay untagged (cassette-only) for exactly this reason. If a redacted value is sent to the live API, recording aborts with an error naming the tagged sanitizer(s) so you can find and untag the offending field.
Caution: only tag field-scoped body sanitizers (e.g. BodyFieldSanitizer)
with scrub_before_read. Do not tag whole-response sanitizers like
DefaultSanitizer or HeaderSanitizer — their header whitelisting would also
apply to the component-visible response during recording, and can strip
pagination or rate-limit headers the component needs to keep working.
Development
uv sync --all-groups
uv run pytest tests/
Metadata
Release files for keboola.vcr 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keboola_vcr-0.7.1.tar.gz | 45.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keboola_vcr-0.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 95.5 kB
Release files / keboola_vcr-0.7.1.tar.gz
| Download URL | keboola_vcr-0.7.1.tar.gz |
|---|---|
| Size | 45.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f4f4557dae473ec43375da46bd69677d78b5fcabd48d443158b5c47771c70d7
|
|
BLAKE2b-256 checksum How to use checksums |
3271abef1086ea6953fa01ab722eeb5c899f31604f2c739ed3a6b8b2f071d76d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / keboola_vcr-0.7.1-py3-none-any.whl
| Download URL | keboola_vcr-0.7.1-py3-none-any.whl |
|---|---|
| Size | 49.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71c6dd1589199b2873a971d9c5409d2ba452ff174b31bffe5e18c8a8091ab1af
|
|
BLAKE2b-256 checksum How to use checksums |
6e892d320232cefc3cc5d7142857f0eb3ac9e3e020fcd9eec0efb43b4205e9b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|